Scenario: I hadn't been coding at home in a while and wanted to kick off my first server client application in C++ using the Visual Studio 2012 Express. But when I clicked the run button, VS froze. There was nothing wrong with the code, so I think the problem lies in some VS settings I'm unaware of, or I accidently downloaded an update which made things worse.
Issue: Hitting the play button (Debug Win32 selected) freezes the VS. Also the taskmanager gets 3 processes of the running program (none which I can interact with). Those processes cannot be terminated unless I reboot the computer.
Specs: Visual Studio 2012 Express, Windows 7, 64 bit. Avast Premier 2015.
#include <iostream>
int main() {
printf("tilt");
return 0;
}
Self-Debugging: I tried making new Hello World programs in new projects, but the issue was still there. If I opened an old project I knew worked before, it also had the same issue without me modifying anything. I changed to C# but still I couldn't run a simple program. I repaired my VS. I installed Visual Studio 2015 Community, but still cannot run any programs.
Error messages:
the process cannot access the file because it is being used by another process
visual studio could not copy exceeded retry count of 10. failed
Microsoft.Common.targets(3390,5)
Linker Tools Error LNK4098
error LNK1168: cannot open tiltTest.exe for writing
error LNK1181: cannot open input file 'kernel32.lib' //after repairing VS
Related links:
Visual Studio Hangs in debug?
Visual Studio 2015 freezes when debugging a cpp code
Windows Forms application remains alive in task manager after hitting "stop debugging" button
Visual Studio "Could not copy" .... during build
Resolving LNK4098: defaultlib 'MSVCRT' conflicts with
visual studio linker warning LNK4098
http://www.bytemedev.com/how-to-fix-visual-studio-error-the-process-cannot-access-the-file-because-it-is-being-used-by-another-process/
Final Words: I'm really bad at linking, settings, libs and anything that isn't code. So if you know how to solve it using those, please expect me to be really beginner as all that is totally confusing and illogical to me. Help would be really appreciated ! If the solution is found, I will modify this post so others will find the solution as well.
Solution: I reinstalled the Visual Studio and turned off Avast, which solved my problems! Thanks for suggestions!
Given the error message about another process using the file it could be down to the antivirus software trying to scan the files at the same time that Visual Studio is trying to access them.
I'd try turning off Avast (or any other anti virus) first. (If you're paranoid about viruses disconnect the computer from the internet).
If everything now works add an exclusion to the AV of your source folders so that it doesn't scan your code - after all you know that there are not going to be any viruses in the executables you create (right?). This will also have the added benefit of speeding up your compiles/links as the AV isn't checking the (potentially) 100's of files you could be modifying each time you build.
Related
I have this build Machine at a remote location. The process of building a full install is that first I update my code via SVN update and then open Visual Studio 2015 Enterprise and build the solution in Release Mode, once that is done I would then open Advanced Installer to build the package to an executable.
But from Friday I am unable to build my code with visual studio 2015, it would seem that build is happening but I am not seeing Build Successful, its been an hour and I had to kill the process(devenv) to Cancel the build.
The only delta which happened from last time is that SVN in my organization is running into some issues in which writes are failing, but logically it doesn't make any sense that visual studio wouldn't build a solution because there is an issue with SVN. I mean, one can argue saying that maybe there is a read error too but I am positive that I have all the necessary code files to build the solution, and for the sake of argument if we say I hadn't, shouldn't I have run into build errors rather than a hung build?
Note 1: Output window is of no use, as I do not see any meaningful error.
Note 2: I checked the solution out in another directory but same result.
Note 3: Build Machine has Windows 7 Professional SP1 in it.
Any insight to this weird behavior is appreciated.
I was able to build the solution after restarting the Build Machine. I looked into the system log to see when was the last time the computer was restarted and to my surprise, I found that it was never restarted even once. I had been using this Machine at least from 2 years.
As I wrote, restarting the PC solved the issue but I do not know the reason which helped the case here. I am guessing there were memory leaks?
Any person reading this post to solve similar issue may want to start by restarting the Build Machine.
I am in charge of testing VS 2015 and how it works with our current applications for my employer. We currently use VS 2013 for everything we have, so I know there are no issues there. The problem I am having is that it appears the vshost.exe isn't terminating correctly or something. I have not narrowed down the exact issue but so far that is what I believe.
Here is how I get my error:
Run my app in debug
Open a few windows
Hit the "Stop Debug" button (the little red square)
Clean Solution
Rebuild Solution
After my rebuild I get the following errors in the EXE:
Error Could not copy "obj\Debug\APP.exe" to "..\..\bin\APP.exe". Exceeded retry count of 10. Failed.
Error Unable to copy file "obj\Debug\APP.exe" to "..\..\bin\CRM.exe". The process cannot access the file '..\..\bin\APP.exe' because it is being used by another process.
If I open the Task Manager and manually end the vshost.exe process I can successfully rebuild again, no issues. If I take the same steps, however, I am no longer able to build.
I tested these steps in 2013 and did not have an issue.
Also note that disabling the "Enable the Visual Studio hosting process" does alleviate the issue, however I do not want to disable this option.
Has anyone else had this issue? I know we are still early in release. Any suggestions/solutions to try? Is it possible there is something wrong in our code (which I highly doubt since I would then get the error in 2013, most likely).
Thanks for any help I receive!
EDIT: This is a WPF application written in .Net 4.0 using C#. Also, I have verified that the issue also occurs if I exit the application normally (IE I open a window then close it with the shutdown mode on LastWindowClosed)
SECOND EDIT: This is a new issue that presented itself in Visual Studio 2015 with the addition of the new live diagnostic tools.
I have found that if I have the "Enable Diagnostic Tools while debugging" option enabled in the debug settings I get this error. If I disable this option, the error goes away. I am not sure if this is a bug in Visual Studio but I would assume so, unless I need to do something else to shut them down properly. If anyone has comments or concerns, feel free to leave a note.
Probably late for the original question (and I see that he had a workaround), but as per MSDN, VSHOST.exe is only an enabler for improving Debug performance or facilitates scenarios such as partial trust debugging. If you do not need that support or can bear the cost of starting a process and attaching the debugger on each debug session, go ahead and disable the hosting process from project designer -> Debug -> Clear the box "Enable Visual Studio hosting process"
When starting Visual Studio 2013 Pro (Update 4 installed) I very often get this error message (several times a day now) for the past about two weeks:
The 'Microsoft.VisualStudio.Editor.Implementation.EditorPackage' package did not load correctly.
I know I can correct this problem by closing Visual Studio and deleting:
%LocalAppData%\Microsoft\VisualStudio\12.0\ComponentModelCache
I have never seen it before that time and as far as I found out in the Internet it was possibly introduced with Update 3.
Well, the problem is that it is annoying to restart Visual Studio several times a day, and I was wondering if anyone else is experiencing this and knows how to solve it for good or what the cause is.
I noticed that it happens extremely often if I work in more than one instance of Visual Studio in parallel. This one is a killer. But still I suspect a third-party component to be involved or it is the size of one of the solutions (about 70 projects). I tried to deactivate some extensions I newly installed and need for the big project, but to no avail.
Just as information: I am working with C#. When working in parallel with projects open in several instances of Visual Studio I never had problems before.
Does anyone have the same problem to this extend or possibly have a better solution than deleting the folder and restarting?
This has become a popular question so I thought I add an explicit answer how to (at least) temporarily fix the problem as already stated in the question:
I stop Visual Studio and delete the following folder (completely, not just contents)
%LocalAppData%\Microsoft\VisualStudio\12.0\ComponentModelCache
If you are using VS2015, then the path should be:
%LocalAppData%\Microsoft\VisualStudio\14.0\ComponentModelCache
If you are using VS2017, then the path should be:
%LocalAppData%\Microsoft\VisualStudio\15.0\ComponentModelCache
I don't keep a backup of the folder. It is created automatically again when starting Visual Studio.
I have never found a solution how to permanently fix the problem in that working environment. In my new developing environment (new projects and new workplace) the problem never happens.
This is what helped me... seemed to happen after Windows Server 2012 SP install...
https://connect.microsoft.com/VisualStudio/feedback/details/1123745/setsite-failed-for-package-microsoft-visualstudio-editor-implementation-editorpackage
devenv /clearcache
devenv /updateconfiguration
In that case you can start Visual Studio setup again and choose the option showing two options, Repair and Uninstall. Then click Repair and when repair is done, restart the computer. Then the issue has been resolved.
After clicking rebuild all, I get the message saying "there were build errors etc" and visual studio freezes completely for like 45 seconds, then returns back to normal.
I have tried to solve this by deleting all sorts of temporary files generated by VS as well as disabling graphic acceleration.
I also uninstalled the VS then re-installed. Nothing helped.
I am running Windows 7 x64 with Visual Studio 2013 Express for Web.
Does anyone have any suggestions?
I had the same problem,
part of my assemblies was at another computer location and there was an access trough UNC between the computers.
I found out that the UNC has a huge latency between the computers.
now every time VS is doing compilation it's going to check all assemblies links at project and this is what make it work so slow.
you can move the ref assemblies to your local PC
or fix the latency.
I have a rather large .NET 2.0 solution (151 projects) in Visual Studio 2008. Often times when I do a build (even for just one project) in VS I get an error saying that it can't copy one of my DLL assemblies to the output directory because it is in use. I don't have any other processes running in the background or existing debug sessions going that would be using this assembly. If I open up Process Explorer and do a search for this assembly name Visual Studio (devenv.exe) comes up as the only result. Looking at the results Visual Studio has my assembly loaded as a DLL for some reason. Closing the solution and reopening it doesn't solve the problem. I have to completely exit out of VS altogether to get around this issue which is quite disruptive. Does anyone have any idea what is going on? I'm running on Window 7, I don't think I saw this issue on Windows XP.
I am running Visual Studio 2008 Version 9.0.30729.1 SP. I'm also running ReSharper 6 if that matters.
Does anyone have any idea what is going on? I'm running on Window 7, I
don't think I saw this issue on Windows XP.
I run into this problem all the time on Windows XP and its not even localized to Visual Studio 2008. What always works for me is I simply clean all solutions, this gets rid of any file that might be in my system's memory, because of Visual Studio.
Visual Studio keeps any your references in memory, so when one of those references is updated, Visual Studio has to release it from memory. If it really happens more then "once in awhile" then you might look at trying to reduce the number of solutions in your project.
Use the following command and place it in "Pre Build Events" of visual studio:
if exist "$(TargetPath).locked" del "$(TargetPath).locked"
Hope this would help you.
Try to disable the hosting process:
Open an executable project in Visual Studio. Projects that do not produce executables (for example, class library or service projects) do not have this option.
On the Project menu, click Properties.
Click the Debug tab.
Clear the Enable the Visual Studio hosting process check box.
Kill process VBCSCompiler.exe and rebuild.
I would guess that the dll is being used by the (ProjectName).vshost.exe process. You might try killing that process and see if that works. Probably not the best thing to do, but it might be easier than restarting VS.
I would try the "Clean Solution" option before you build. This can clean up any extraneous temp files that could be hanging around from a program crash.
I have no idea about why this works, but I had the same problem and when I changed the Starting Project to the project I wanted to build everything worked again.
When I change the Startup project again to the right one I cannot build the other project anymore due to the file being in use, so looks like a bug at the Visual Studio IDE.