Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / December 2004

Tip: Looking for answers? Try searching our database.

Using AppDomain to get Assembly Version Info

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mark Olbert - 04 Dec 2004 02:26 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.