Web
Site
Register
::
Login
Forums
September 09, 2010
Forums
Unanswered
Active Topics
Forums
Search
Forums
>
Programming - Dotnet / Delphi
>
Compact Framework
Subject: Get assembly version - locked forever
Prev
Next
Add Reply
Author
Messages
Oldest First
Newest First
Don
New Member
Posts:20
04/07/2005 7:47 AM
Quote
Reply
Recently, I downloaded some CF sample code that compares the version number of a program running on a mobile device with a version number returned from a web service. If they didn't match, a new version of the program was downloaded cab file and shellexec'd to install it. For some unknown reason, the programmer decided that the program that does the comparing and updating should close immediately after shellexec. Now I think I see why: The program loads the assembly to get the version number like so:
...
Assembly a = null;
AssemblyName assname = new AssemblyName();
// If assembly does not exists, presume the version to be 0.0.0
assname.Version = new Version('0.0.0');
// Try obtaining assembly version
try {
if ( File.Exists(aProgramPath) ) {
a = Assembly.LoadFrom(aProgramPath);
assname = a.GetName();
}
} catch(Exception) {
}
// Release assembly, so that its file is not locked anymore
a = null;
...
The last part simply doesn't work. The assembly remains locked until the program that called it is closed. This means that after checking the version number, you can't install it because you've got it locked.
There is apparently no way to release the lock in CF. In the 'regular' framework, you would load the assembly into an AppDomain and the locked assembly will be released when the AppDomain is destroyed. But the CF doesn't support AppDomain.
Another option is to first copy the assembly and get the version from that. That's an option if you have the space on the device to hold two copies of your programs. That's necessary because you can't delete the copies because they're locked.
There are ways around this but they are hacks. One way would be to have a separate program that checks version numbers that is called from the main update program. You can pass it the name of the assembly and it can output its results to a file or something.
Add Reply
FAQ
--General FAQ
Experiences
--Comments, complaints about anything
--Customer Service
Music
--New Music Notifications
--General Music
--St. Alphonzo's 2010
--St. Alphonzo's 2009
--St. Alphonzo's 2008
--St. Alphonzo's 2007
--St. Alphonzo's 2006
--St. Alphonzo's 2005
Programming - Dotnet / Delphi
--General DotNet
--.Net Framework Code Snippets
--ASP.NET Tips and Snippets
--Compact Framework
--Compact Framework Code Snippets
--Delphi
Forums
>
Programming - Dotnet / Delphi
>
Compact Framework
> Get assembly version - locked forever
Quick Reply
Username:
Subject:
Body:
Submit
Home
Forums
Bluto Band
Music
Music Videos
Photographs
Download
Liquid Mix
ERG 40
Favorite Links
Home
|
Forums
|
Bluto Band
|
Music
|
Music Videos
|
Photographs
|
Download
|
Liquid Mix
|
ERG 40
|
Favorite Links