简体   繁体   中英

How can I update System.Data.SQLite.DLL from an application that uses it?

I have a .NET application that is just an updater for another application. However, Updater uses SQLite to query a database for proxy settings to download the updates from the server. I need to update the SQLite DLL, but of course I get "The process cannot access the file 'C:\Program Files\XXXX\System.Data.SQLite.dll' because it is being used by another process.".

I see on Wikipedia " SQLite is not a separate process that is accessed from the client application, but an integral part of it." But that doesn't seem to be the case.

Can anyone think of a workaround?

If you need to update a library that your application uses, you should use late binding to load the library so you can de-allocate it on demand and then overwrite the file. You are probably early binding it now which will preclude any overwrite while your process is running.

Assuming you have a "main" app that runs the updater app - grab the proxy settings from the main app, then pass them to the updater app on its command-line.

Another option - if your updater app lived in C:\Program Files\XXXX\Updater\, you could update the copy of the SQLite DLL in the main folder without running into conflicts. This isn't ideal, though - you end up with 2 copies of the DLL, and your main app would probably want to update the SQLite DLL in the Updater folder.

And another option - move the proxy configuration settings to something other than a SQLite database. A XML settings file would work pretty well for something like that, and libraries to serialize/deserialize it are built-in to .NET.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM