问题
When we're releasing new code to production, we often need to update .cs files in the App_Code directory. Frequently, if there are any users in production (and there are always some, even overnight), we'll get an error message on any application page load:
The assembly 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET
Files\root\a18f28ce\a6daf424\App_Code.dll' is already loaded in another appdomain.
The only way we've found to get the application to respond again is by restarting IIS. Trouble is, now, that IIS will frequently fail to come back up. We restart IIS by going into the IIS manager, clicking on the server name, and then clicking Restart on the right. The system will think for several seconds, and then give the error:
Timeout error. W3SVC failed to start.
The only solution at that point is to restart the server, which we want to avoid on a production server.
Any ideas on how to troubleshoot the IIS timeout error, or (ideally) how to avoid the "already loaded in another appdomain" error in the first place?
回答1:
An easier/automatic solution to the above is to use an ~/App_Offline.htm file as part of your deployment process (a feature baked into IIS so WebDeploy can avoid file locking issues).
Modify your deployment process so the first step is to create App_Offline.htm in the webroot. IIS will detect this file and promptly bring down the app domain - releasing any locks etc. Deploy your application as normal without any locking issues, and when your finished, delete the App_Offline. The next request IIS receives will start the app domain loading your newly deployed version.
Whatever content you place inside the App_Offline.htm file is returned by IIS for all requests until you remove the file.
回答2:
Go to Task Manager --> Processes and manually stop the W3SVC process. After doing this the process should start normally when restarting IIS
Note: It could also be the Svchost process
Go To Process to find the right svchost to terminate
回答3:
Try restarting IIS from the command prompt (administrator) using:
iisreset
or
iisreset /stop
and then
iisreset /start
Note: May need to restart the worker process
来源:https://stackoverflow.com/questions/53303344/iis-fails-to-restart-with-a-timeout-error