Hi all,
I'm writing some code to automatically update my application when
changes have been made. I had it all working by using the LoadFrom
method of an assembly and checking the version information, etc...
until I realized that was actually locking the files on the common
drive where the updated app is located. I know the solution to this is
to load the assembly into another appdomain, then check and unload it,
but I can't seem to get it loaded into the other domain.
For testing, my version is 1.3 and the shared version is 1.5, so I
should get new components when I start the app. When I changed it to
use the load method from the new domain, it only wanted to load the 1.3
(old) version. So I've been messing with the
CreateInstanceFromAndUnwrap method and not having any luck. It is
throwing exceptions about not being able to load the assembly.
here is the code, hopefully someone can tell me what I'm doing wrong or
even better, the correct way to do it.
'mIBBaseHome is the path where the updated version exists
'mIBEXEName is the name of the application
Dim chkInfo As New AppDomainSetup
Dim adevidence As Evidence = AppDomain.CurrentDomain.Evidence
chkInfo.ApplicationBase = mIBBaseHome
chkInfo.ShadowCopyFiles = True
chkDomain = AppDomain.CreateDomain("CheckNewVersion", adevidence,
chkInfo)
assblyNewExe = chkDomain.CreateInstanceFromAndUnwrap(mIBBaseHome &
mIBEXEName, "MyMod.Main") <-- throws "can't load' exception -->
Since all I need is the version info, i thought for the "Type" I should
just use the Sub Main method, although I'm really not sure what the
type (in the create method call) should be.
Thanks,
Mark