hello CAPSKOL,
The only way of unloading an assembly (as far as i know ) is by unloading the application domain that holds the assebly.
Check the following link on MSDN
I know that it's impossible to unload a assembly. Only the appDomain . . .
But
I need to load and unload a assembly . . .
I am trying to do this . . .
------------------ cut here --------------------------
Public Sub Load(ByVal libraryName As String)
Try
Dim cont As Long
Dim controleDomainApp As AppDomain
If Dir(System.Environment.CurrentDirectory & "\" & libraryName) <> "" Then
' Checando se a dll ja nao esta carregada.
For cont = 1 To colecaoNomesDLL.Count
If colecaoNomesDLL(cont) = libraryName Then
Exit Sub
End If
Next
colecaoNomesDLL.Add(libraryName)
Dim setup As AppDomainSetup = New AppDomainSetup()
setup.ApplicationBase = System.Environment.CurrentDirectory
setup.PrivateBinPath = AppDomain.CurrentDomain.BaseDirectory
setup.ShadowCopyFiles = "false"
setup.ShadowCopyDirectories = libraryName
controleDomainApp = AppDomain.CreateDomain(libraryName, Nothing, setup)
controleDomainApp.Load(System.Reflection.AssemblyName.GetAssemblyName(libraryName))
colecaoAppDomain.Add(controleDomainApp)
End If
Catch err As Exception
tratadorErro.trataErro(err)
End Try
End Sub
------------------ cut here --------------------------
This method to load a assembly
And this to unload a assembly
------------------ cut here --------------------------
Public Sub Unload(ByVal libraryName As String)
Try
Dim cont As Integer
' Checando se a dll ja nao esta carregada.
For cont = 1 To colecaoNomesDLL.Count
If colecaoNomesDLL(cont) = libraryName Then
AppDomain.Unload(colecaoAppDomain(cont))
colecaoAppDomain.Remove(cont)
colecaoNomesDLL.Remove(cont)
GC.Collect()
Exit Sub
End If
Next
Catch err As Exception
tratadorErro.trataErro(err)
End Try
End Sub
------------------ cut here --------------------------
But, in the method load, the main AppDomain loads the assembly too . . .
How can i do to the AppDomain not load the assembly, the AppDomain must uses the assembly of other appDomain.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.