Assembly Locked

Jul 31, 2009 at 3:13 AM

Since this is the closest thing I could find to a dedicated T4 newsgroup, I thought I'd post here.  I'm using FxCop's AssemblyNode.GetAssembly to load assemblies (while putting in a using block to ensure it is disposed) and I'm getting the following error on one of my assemblies:

"Unable to copy file "...dll" to "...dll". The requested operation cannot be performed on a file with a user-mapped section open."

I thought that using AssemblyNode.GetAssembly keeps this sort of thing from happening?  Is there a way to debug the process that has a lock on this assembly?

Thanks for any help anyone can provide. :)

-- Michael


Jul 31, 2009 at 12:46 PM

I don't remember having this problem when I was working on this generator. In fact, FxCop SDK/Introspection was a solution to an assembly locking problem I was having when using Reflection. The assembly was locked by T4 and the error was coming from Visual Studio when recompiling the locked assembly. The best way I can think of to debug this problem is with ProcessExplorer which can tell you who is locking the assembly when you get the error.