How to unload the assembly?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a problem... A webservice I built check the version of an assembly by
using this code:
app = [Assembly].LoadFrom(Server.MapPath(appName & "\" & assemblyName))
' Return it's version
Return app.GetName.Version.ToString

when another app is uploading a new version of that file I get a
securityexception stating the file is in use...

The ony code i have that accesses that file is the above code... so what is
going on?

I can't unload an assembly without disposing the entire app domain...
/Henrik
 
To get assembly information, you would be better off using the AssemblyName
class:

Private Function GetAsmVersion( _
ByVal sAssemblyFileName As String) As String
Dim asmName = _
AssemblyName.GetAssemblyName(sAssemblyFileName)
Return asm.Version.ToString
End Function

GetAssemblyName loads the file, extracts the information and then closes
back the file. The assembly is not loaded into the app domain and so you
don't have to deal with unloading it from the app domain.

hope that helps..
Imran.
 
Back
Top