Why does IIS Express lock files stopping build, rebuild and clean in ASP.Net Core? - iis-express

Every once in a while (and happening to me right now) I'll have a project and something goes wrong and I don't know what.
It will just stop me from building my project.
It just writes this out a million times for each file:
Severity Code Description Project File Line Suppression State
Warning MSB3026 Could not copy "obj\Debug\netcoreapp3.1\WebApp.dll" to "bin\Debug\netcoreapp3.1\WebApp.dll". Beginning retry 1 in 1000ms. The process cannot access the file 'bin\Debug\netcoreapp3.1\WebApp.dll' because it is being used by another process. The file is locked by: "iisexpress.exe (10396)" WebApp C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets 4183
IIS is not even in my tray.
How do I kill the process?
And why in the world does it do this in the first place?
Very annoying. Lose to much time for this stupid thing.

Open the Task Manager => find out the IISExpress process => end task. Now you can compile the code. this does not need Visual Studio restart.

Related

The file is locked by: "w3wp.exe" after windows update

I' ve an ASP.NET CORE project with IIS, Im using this about 1 year without problems.
Yeserday I update windows 1909 to 21H2 and im getting all the time these errors on visual studio:
"The process cannot acces the file ... (DLL) because it is used by
another process"
"Exceeded retry count of 10. Failed. The file is locked by: w3wp.exe"
So i can't publish updates on my software.
I see that on executing process, the w3wp.exe is duplicated when i try to publish.
So now, to publish the project i must close manually all these processes and then publish it.
This "solution" works sometimes; but it's so realy realy boring
Is there a way to solve this error?
I tried to search many solutions, but nothing works.

Visual Studio 2010 SP1 is locking and preventing itself from building the project target assembly

I have a project, which contains various classes and user controls. Every once in a while, often on the second build attempt, Visual studio locks the project's target assembly and the build fails with the following error:
Unable to copy file "obj\x86\Debug\MyProject.dll" to "bin\x86\Debug\MyProject.dll". The process cannot access the file 'bin\x86\Debug\MyProject.dll' because it is being used by another process.
This same issue was reported here: VisualStudio2010 Debugging - The process cannot access the file ... because it is being used by another process. I tried a few of the presented answers, but none of them resolved the matter for me.
Any suggestions?
I read somewhere it's a known issue and they're working on a hotfix - knowing Microsoft it should come out about the time Windows 9 does.
The current only real fix is to uninstall SP1, but since I can't be bothered doing that I just delete all the project files in the Debug folder, but you have to do this every time it throws the error. You can't use a program or batch file to do this since for some reason it completely locks the file and you have to wait ~5mins for the system to unlock and delete it.

DLL Caching Issue, Used By Another Process in Visual Studio

Of all the projects I have worked on I keep this this error below with multiple referenced projects. I keep having to clean it and then build. I feel like I am in Eclipse but this is happening in Visual Studio. This has never happened before, any tips on what to check?
Error 53 Unable to copy file "C:\Development\Projects\Pearson\ARIES\Development\Projects\ARIES.Web.Models\bin\Debug\ARIES.Web.Models.dll" to "bin\ARIES.Web.Models.dll". The process cannot access the file 'bin\ARIES.Web.Models.dll' because it is being used by another process. ARIES.Web
Found the answer here
Edit your project file and add this to the first PropertyGroup:
<GenerateResourceNeverLockTypeAssemblies>true</GenerateResourceNeverLockTypeAssemblies>

Build error in VS 2010

I am getting this error in my application
Error 1 Unable to copy file "D:\myproj\bin\Debug\myproj.dll" to "bin\Debug\myproj.dll". The process cannot access the file 'bin\Debug\myproj.dll' because it is being used by another process.
How to fix it
Your project dll is being used by another process. Either you ran your application and it didn't fully shut down (check the task manager) or some other program is trying to consume the dll in the d:\myproj\bin\debug\myproj.dll
For example, in the olden days, if you used a .Net dll in a VB6 app, and pointed to the debug dll, it would grab on to that and you'd have to shut down VB6 to free the dll.
I suspect you'll have to do something similar.
Start by checking task manager and making sure your app isn't still running.
Then close down any other apps that have a reference to your dll
If neither of those two work, close down studio and restart it

Cannot compile solution in VS due "Attempted to access an unloaded AppDomain" -- how to pin it down?

I have a C#/ASP.Net solution in VS (2008) with several projects within it. When I try to compile it I get one error only:
Attempted to access an unloaded AppDomain
No line code, no project name, nothing. Just such error.
How can I pin down this error -- i.e. the cause, or even better -- how can I solve it and continue compilation?
Thank you in advance.
Shut down Visual Studio and reopen it. Then clean the Temp folder.
For that press Windows+R and type %Temp% and click Ok, then delete everything.
If this error comes with VS follow these steps
Just restart your VS.
Start VS again
Clean the solution (Build> Clean Solution)
Rebuild your project again
If this error comes with IIS
Restart (recycle) the IIS Application Pools in IIS Manager, After restarting check run the solution again!
There are many possibilities:
Try resetting your Visual Studio's
Setting.
Or check all dlls which are
referenced.
Check all the namespaces which are
being used in your application, Do
they exist?
I am experiencing the same in Visual Studio 2012 - but ONLY on websites hosted on UNC share. My solution (when it occur) is to unload the web project and reload it again. Then in works for some time again.
The problem as I recall it is, that the hosted UNC share (or the workstation trying to access it) is running an x86 version of Windows, which does not allow to many open network connections.
In my experience these sort of problems disappear on true x64 environments.
Cheers.
it means, there is something in WebConfig/AppConfig not compatible and cannot load.
For ex.
İf you published project, check app_data/publish profiles, delete them.
Check your .sln file first if it is conflicted then delete it and update your svn folder and rebuild your solution.
Rebuild your solution
It's also possible that your unit test started up a thread but didn't close it. Ensure your threads are all closed before completion.
It might be a good idea to verify all your unit tests are running and passing correctly.
Exit the local webserver(IIS express) from the system tray and delete asp.net temp files from temporary folder & then try clean,rebuild and run your application
Following are the steps i followed to get rid of such error-
Press Windows+R , write %Temp% and hit enter. Now,delete all the temporary files from the directory.
Restart your visual studio.
Clean your project solution from Solution explorer in Visual studio List item.
Rebuild the project & Run .
It should work expected.

Resources