How to update existing DLL's in an ASP.Net application?
-
Hi, Here the situation: I have some ASP.Net web services that get installed on multiple client web servers and I want the ability to provide automatic updates. To accomplish this, I have put together a desktop application that contains an application updater that download & checks the update manifest, downloads any updated files, then copies them the to web service's bin directory. I also have a Windows Service that launches the desktop application (silently) on a timed basis, but that's immaterial. The problem is the updater cannot overwrite any DLL's in the web service's bin directory - I have tried direct overwriting while downloading, and also copying them to a temp directory and using File.Copy and File.Move. Nothing works. The error returned is: Error processing application update manifest: System.IO.IOException: The process cannot access the file "C:\Inetpub\wwwroot\[Name and Path Removed].dll" because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite) at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite) at AppUpdater.HttpDownloader.DownloadToFile(DownloadItem item) at AppUpdater.HttpDownloader.ProcessQueue(DownloadQueue downloadQueue) at AppUpdater.ApplicationUpdater.downloader_DownloadComplete(Object sender, DownloadCompleteEventArgs e) I've never had a problem overwriting any files in the bin directory as a user - as I understand it, overwriting an ASP.Net application file is a perfectly OK thing to do, as the ASP.Net process uses shadow copies of everything anyway. The desktop application doing the updates is running under my user account, so I would therefore expect it should be able to overwrite DLL's in the bin directory just as I can do manually. Note that the updater is NOT trying to ovwerite any DLL's/Exe's it references - the files it's updating have nothing to do with the updater itself. Any ideas how I can programatically replace DLL's for a running ASP.Net app?
-
Hi, Here the situation: I have some ASP.Net web services that get installed on multiple client web servers and I want the ability to provide automatic updates. To accomplish this, I have put together a desktop application that contains an application updater that download & checks the update manifest, downloads any updated files, then copies them the to web service's bin directory. I also have a Windows Service that launches the desktop application (silently) on a timed basis, but that's immaterial. The problem is the updater cannot overwrite any DLL's in the web service's bin directory - I have tried direct overwriting while downloading, and also copying them to a temp directory and using File.Copy and File.Move. Nothing works. The error returned is: Error processing application update manifest: System.IO.IOException: The process cannot access the file "C:\Inetpub\wwwroot\[Name and Path Removed].dll" because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite) at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite) at AppUpdater.HttpDownloader.DownloadToFile(DownloadItem item) at AppUpdater.HttpDownloader.ProcessQueue(DownloadQueue downloadQueue) at AppUpdater.ApplicationUpdater.downloader_DownloadComplete(Object sender, DownloadCompleteEventArgs e) I've never had a problem overwriting any files in the bin directory as a user - as I understand it, overwriting an ASP.Net application file is a perfectly OK thing to do, as the ASP.Net process uses shadow copies of everything anyway. The desktop application doing the updates is running under my user account, so I would therefore expect it should be able to overwrite DLL's in the bin directory just as I can do manually. Note that the updater is NOT trying to ovwerite any DLL's/Exe's it references - the files it's updating have nothing to do with the updater itself. Any ideas how I can programatically replace DLL's for a running ASP.Net app?
Well, that's exactly the problem... the application is running X| you need to reset iis (iisreset) before trying to overwrite the file. My experience has been that after debugging a web application, I tried to manually delete the dll files within the bin folder, guess what, the operating system told me the files couldn't be removed because "they were being used by another user or process". So what I do is run iisreset and then I remove the dlls without a problem. You need to somehow stop the execution of the web application. daniero
-
Well, that's exactly the problem... the application is running X| you need to reset iis (iisreset) before trying to overwrite the file. My experience has been that after debugging a web application, I tried to manually delete the dll files within the bin folder, guess what, the operating system told me the files couldn't be removed because "they were being used by another user or process". So what I do is run iisreset and then I remove the dlls without a problem. You need to somehow stop the execution of the web application. daniero
Thanks for the suggestion, but unfortunately it didn't work.. I tried both "iisreset /STOP" and "net stop iisadmin", but am still getting the same exception when trying to copy the updated file from the temp directory to the bin directory. The whole point is you *should* be able to replace a "running" ASP.NET file because it's not actually running - the ASP.NET process creates a shadow copy, which should mean it's released immediately after the ASP.NET application starts. The fact that I can manually replace the file via Windows Explorer only serves to increase my frustration. bah.
-
Thanks for the suggestion, but unfortunately it didn't work.. I tried both "iisreset /STOP" and "net stop iisadmin", but am still getting the same exception when trying to copy the updated file from the temp directory to the bin directory. The whole point is you *should* be able to replace a "running" ASP.NET file because it's not actually running - the ASP.NET process creates a shadow copy, which should mean it's released immediately after the ASP.NET application starts. The fact that I can manually replace the file via Windows Explorer only serves to increase my frustration. bah.
Got it.. All my fault too. The updater checks the currently installed version by loading the assembly and calling Assembly.GetName().Version, which then locks the assembly. Doh :doh: Funny how I expected ASP.Net to shadow copy the assembly, but didn't do it myself. What a brain fart that was. Nothing to see here folks, please return to your homes.
-
Thanks for the suggestion, but unfortunately it didn't work.. I tried both "iisreset /STOP" and "net stop iisadmin", but am still getting the same exception when trying to copy the updated file from the temp directory to the bin directory. The whole point is you *should* be able to replace a "running" ASP.NET file because it's not actually running - the ASP.NET process creates a shadow copy, which should mean it's released immediately after the ASP.NET application starts. The fact that I can manually replace the file via Windows Explorer only serves to increase my frustration. bah.
I get your point, since the web app actually runs somewhere in windows folder :doh: sorry I can't help you more with that. Any one else has suggestions? daniero