Shared violation with Assembly.LoadFile

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've created an application on Pocket PC. I'd like to let the application be
able to download an updated version if it's available. The way I did is to
take the version number of the local exe file and send it to the server
through a web service, and then compare it with the version number on the
server.

It worked OK until you have several hit of the web service. The exe file on
the server side is locked, i.e. you won't be able to either delete it or
overwrite it. The problem stays until you reboot the machine. The problem
stays if you stop/start the IIS service. Is any one could give me some hints?

I'm using the following code:

string servVer = Assembly.LoadFile("myExe").GetName().Version.ToString();
 
My suggestion - load it once when the ASP.NET application starts up and
cache the version in the global context and then unload the exe. You may
also watch the file such that if it changes, you read load it and cache the
new version number. It is presumably imperative that you unload the assembly
otherwise the file will be locked on disk.

However, I don't really like the idea of loading compact framework
assemblies into the server context to get their version number. Can't you
find some other way? e.g. get a hash of the file or store its version in
another place such as web.config.

- John
 
Back
Top