G
Guest
I am trying to create and instantiate a class into a created domain, so that I can unload the domain and replace the class (assembly .dll) while the main application is running, but I can't get it to work for some reason.
Here is the code:
' Create an appdomain
Try
Dim setup As AppDomainSetup = New AppDomainSetup
setup.ApplicationBase = "C:\test"
setup.PrivateBinPath = AppDomain.CurrentDomain.BaseDirectory
setup.ApplicationName = "MyDomain"
appd = AppDomain.CreateDomain("Domain", Nothing, setup)
Catch ex As Exception
MsgBox("Can't create domain: " & ex.Message)
End Try
' Loads an class into the newly created appdomain
Try
Dim test As Object = appd.CreateInstanceFromAndUnwrap("CAP Fast.dll", "CAPfast")
Catch ex As Exception
MsgBox("Can't initiate the class: " & ex.Message)
End Try
Creating the domain works, and the CreateInstanceFromAndUnwrap method finds the DLL, but it can't find the class according to the error message. I don't have any explicit namespace, and the class is called CAPfast, with the correct case. The class also have a public constructor without any arguments.
Anyone have any idea why this isn't working?
Here is the code:
' Create an appdomain
Try
Dim setup As AppDomainSetup = New AppDomainSetup
setup.ApplicationBase = "C:\test"
setup.PrivateBinPath = AppDomain.CurrentDomain.BaseDirectory
setup.ApplicationName = "MyDomain"
appd = AppDomain.CreateDomain("Domain", Nothing, setup)
Catch ex As Exception
MsgBox("Can't create domain: " & ex.Message)
End Try
' Loads an class into the newly created appdomain
Try
Dim test As Object = appd.CreateInstanceFromAndUnwrap("CAP Fast.dll", "CAPfast")
Catch ex As Exception
MsgBox("Can't initiate the class: " & ex.Message)
End Try
Creating the domain works, and the CreateInstanceFromAndUnwrap method finds the DLL, but it can't find the class according to the error message. I don't have any explicit namespace, and the class is called CAPfast, with the correct case. The class also have a public constructor without any arguments.
Anyone have any idea why this isn't working?