I'm trying to write a very simpleminded web-based system to keep an application current. The basic
concept is that my application calls a webservice each time it starts to see if there are any
updated assemblies to download. If there are it downloads them and restarts itself (this is only the
barest outline). An assembly needs to be updated if the webservice's copy of it has a version higher
than that of the remote application.
This works fine as currently written, but there's a side effect I'd like to eliminate. Right now the
webservice gets the version information by calling Assembly.LoadFrom() on each of the files in its
"manifest". This, of course, loads the assembly into the website's AppDomain... and I can't unload
them, so whenever I upload new versions of the DLLs I get "file locked" errors on the DLLs I'm
trying to replace (because they've been loaded into the website's AppDomain). This requires that I
restart my website...which is a pain.
I thought I could get around this by creating a temporary AppDomain in the webservice, loading the
DLLs into it, extracting the version information I need, and then unloading the temporary AppDomain.
Unfortunately, there does not appear to be an analog of the Assembly.LoadFrom() method in the
AppDomain class.
Whenever I try to use one of the AppDomain.Load() methods, I get an "insufficient state, object
can't be serialized (or deserialized or whatever)" exception. I suspect this is a security/evidence
problem, but I'm not sure.
1) Is there a simpler way to extract the version information I need from an assembly without
actually loading it?
2) Is there a way to duplicate the behavior of Assembly.LoadFrom() within an AppDomain?
Thanx in advance for any help or advice!
- Mark
Mark Olbert - 04 Dec 2004 06:37 GMT
Okay, I'm a nimrod, I never saw that there is a FileVersionInfo class which does >>exactly<< what
I'm looking for.
Sorry to bother everyone.
- Mark
David Levine - 04 Dec 2004 11:58 GMT
In addition to the file version info, you can also use the AssemblyName
class to get information about an assembly without loading it up into the
appdomain.
> Okay, I'm a nimrod, I never saw that there is a FileVersionInfo class
> which does >>exactly<< what
[quoted text clipped - 3 lines]
>
> - Mark