Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

error MSB3021: Unable to copy file "obj\Debug\Common.DataAccess.dll" to "bin\Debug\Common.DataAccess.dll". The process cannot access the file 'bin\Debug\Common.DataAccess.dll' because it is being used by another process.
Done building project "Common.DataAccess.vbproj" -- FAILED.

 

I call a Macro that loads the "bin\Debug\Common.DataAccess.dll" file into an Assembly instance, then I use getTypes() to run through all the types and I copy some names off into a collection for use in the Macro.

 

At this point, I set the assembly instance = to nothing. There isn't any Dispose or ReleaseAssembly.

 

But when I attempt to rebuild the "Common.DataAccess.dll", I get the error that it's in use.

 

Looking at various pages, MS's example doesn't even set the assembly to nothing and most of the examples only set the instance to nothing.

 

None of it's methods/properties seem like they would help. So how can I force this to release it's hold on the file?

 

Here is the code I'm roughly using:

 

       Dim assData As Reflection.Assembly
       assData = Assembly.LoadFrom(Path)

       For Each typeData As Type In assData.GetTypes
           If typeData.FullName Like "TableAdapter" Then
               ' Code to copy text from the type
           End If
       Next

       assData = Nothing

 

I load it, I get it's types and then set it to nothing.

Edited by Denaes
Posted

Marble_Eater suggested using the AppDomain as well in another thread.

 

But... there is always a but.

 

I'm doing this at design time, not runtime. An Assembly can only be loaded into one AppDomain at a time and because the Assembly I'm loading is loaded into the projects (or solutions, I'm not sure) AppDomain, I can't load it into a new AppDomain.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...