Unable to copy file .exe in Visual Studio 2017 - c#

I have an asp.net core project that references .NET Framework and I'm using Visual Studio 2017 Enterprise. When I try to build my solution, I came across with this error:
Unable to copy file "obj\Debug\net461\MyProject.exe" to "bin\Debug\net461\MyProject.exe".
Access to the path 'bin\Debug\net461\MyProject.exe' is denied.
Even if I cleaned the solution and build again, I still have this error.
Anyone faced this error?

Go to Task Manager and look for Microsoftvshost.exe and kill them all. Even though you stop debugging the exe can continue to run in the background. This causes a lock on the file.

Close the application and delete Obj and bin folder

First, make sure you have the .net core localhost server stopped, before trying to build the solution.

I have seen this error before. Trying the following has worked for me:
1. Close the current solution.
2. Close Visual Studio.
3. Start Visual Studio in Administrator mode.
4. Re-open and build the solution.
The above can avoid the common copy file and file Access Denied errors.

Related

Visual Studio 2019 "attach" instead of "start" issue

Basically, after installing visual studio on my second computer I went to make a simple console application. Instead of saying start or letting me run the program it would just say attach. It works perfectly fine on my other computer and I downloaded vs the exact same way on both.
I also tried doing "dotnet --version" in the command prompt on both computers and the computer that works is able to find a .NET version on my computer but the one with the issue cant, it says I haven't downloaded it... when I go to download .NET separately it still doesn't work.
In my solution explorer it says "0 projects" even though I clearly have a project file in the folder along with the solution. When I try to add an existing project it simply doesn't let and says "The project file cannot be opened. Unable to locate the .NET SDK. Check that it is installed and that the version specified in global.json (if any) matches the installed version".
I also tried the solution from this thread: Microsoft Visual Studio 2019: The project file cannot be opened. Unable to locate the .NET SDK
and it didn't change anything.
I've tried reinstalling and repairing visual studio and even that didn't help at all.
If any of you have any idea what I could do to fix this that'd be great!
That usually happens when you open the project from the project file, from the folder that contains it, instead of opening it from VS. Try open VS first, and then browse to open your project and should work. Another way to solve it is clicking on "reload" once the project is open.
Some other times it happens when you open the (.cs) file instead of the project file. Attach - start issue

Error reported in web.config, but only when it is not open in the editor in Visual Studio Community 2015

I just changed to Visual Studio Community 2015 and I'm having a weird issue running a project. The project builds without any errors. But, when I go to start debugging I get the following error:
There is an error in web.config. Please correct before proceeding. (You might rename the current web.config and add a new one.)
This only happens if web.config is not open in the editor in Visual Studio. If I open web.config in Visual Studio and try to run the project, I am able to do so and no errors are reported.
Has anyone suggested that we close and reopen Visual Studio?
I had the same problem in a Web API project in VS Enterprise 2015. I knew there was nothing wrong with the Web.config file because, like you, all I had to do was to have it open before hitting F5. It went away after I removed and re-added the project to the solution during solution re-organizing. You might want to try that. No logics here but then the error seems illogical too.
I fixed/stopped the issue above and wanted to communicate what my fix was with the exact same symptoms as above. I had switched to a different published environment when this started happening (from UAT to Dev) and I commented out a section in the web.config file. Double checked to make sure I commented out the exact text. I even cleaned my solution and rebuilt it, same problem. Strangely, I could publish to the dev environment and the application would run (Web app with IIS 7).
The only difference between my local environment from when it was working and this problem was my web.config file. So I was thinking VS was having trouble accessing the file when not open in the IDE. I checked properties and the file had the appropriate settings. I then checked in the solution into our source code repository and the issue went away. We implement an SVN solution here.
Hope this helps.

Metadata file 'System.EnterpriseServices.Wrapper.dll' could not be opened -- 'Error importing module 'System.EnterpriseServices.Wrapper.dll'

OS: Windows 8.1
Visual Studio Premium 2013
I have a complex MVC application that I have been running for years. I am able to run the application in debug without issues. However, just this afternoon, when I tried to publish the application for deployment I receive this error:
Error 8 Metadata file 'f:\Documents\Visual Studio 2013\GIT\Maloha\site\bin\System.EnterpriseServices.dll' could not be opened -- 'Error importing module 'System.EnterpriseServices.Wrapper.dll' of assembly 'f:\Documents\Visual Studio 2013\GIT\Maloha\site\bin\System.EnterpriseServices.dll' -- The system cannot find the file specified. ' F:\Documents\Visual Studio 2013\GIT\Maloha\site\CSC site
I have restarted my computer.
I have tried to clean and rebuild the application.
What would cause this to suddenly appear? How do I fix it? I need to be able to publish the application.
UPDATE
I uninstalled .NET 3.5 and reinstalled it. I can now see the file in the specified folder, but I still get the error.
I had a similar issue. I have no idea if my solution will work for you, but here is what someone told me to do:
Delete the files from the bin folder so they can be rebuilt with the next publication.
I have no idea why it worked, but I was able to use the solution after that.
Unfortunately, I can't provide any additional insights or directions beyond this.
Clean the project or delete the files from bin folder and then rebuild it again, it happened with me twice and that was the solution which solved my problem

Install Sheild LE -4340 Internal Build Error Visual Studio 2012

I have an issue with building an MSI with Install Shield LE in Visual Studio. The error says "-4340: Internal Build Error", but the link to Flexera is worthless. I tried the suggestion in another post to add the installer project to a fresh solution and then my .Net projects after, but that did not help. That suggestion can be found here.
I have not found a single repeatable cause of the issue, it does not seem to happen because of any one thing. I'm trying to build an installer for a Windows Service.
I got that error too. In order to fix it i rebuild my solution in Release configuration instead of Debug one.
All I did is restart Visual Studio. For some reason that worked for me.
My solution is slightly different:
Close and launch Visual Studio, open solution then
Rebuild with Release configuration AND
Unload/load InstallShield
Setup:
Visual Studio 2015, Windows 10, Visual C#
When I had this error, it was because I added an executable for extra dialogs to be run after the install. I told install shield to run the executable, but I didn't add it to the list of files to deploy.
When I added it to the files, the error went away.
It could be that when users switch to "debug" that they have a build of the executable in debug mode, but they never built it in release mode.
It would be nice if flexera produced a normal error message for my case at least. i.e. "You said to run XYZ, but XYZ is not found in the file list"
I had the same issue and solved it by deleting a previous build. It looks like Visual Studio wasn't able to delete the previous version.
I am quite late to this post... but I will post the solution in case others run into the problem. I worked with Flexera on this problem and they provided a fix for it. Download and install IS 2016 SP1 or newer and the problem is solved! Read all about it at
https://community.flexerasoftware.com/showthread.php?220123-ISDEV-error-4340-Internal-build-error&p=509912
I just had this again for the x-thousandth time. Normally the rebuild approach works, or failing that restarting VS, but this time I actually had to restart Windows to get it working again. Hope that helps someone, I was starting to really think it wasn't going to work again this time.
I had to unload/reload the InstallShield project in order for it to build.
I'm getting this error when I forget to start Visual Studio with Administrator privileges.

Visual Studio 2012 csc.exe Error. Executable not valid for OS

I am getting the following error when trying to compile and test any type of project in Visual Studio 2012 Professional.
Error 1 The specified task executable "Csc.exe" could not be run. The
specified executable is not a valid application for this OS platform.
After testing multiple suggestions online nothing has fixed the problem. Anyone know what is causing this? Is there a new version of Csc.exe I need to get a hold of? I know this is the compiler just not sure what I need to do to fix the problem.
I had this exact problem today on my Win7 Machine. As Hans suggests, 'Navigate to C:\Windows\Microsoft.NET\Framework\v4.0.30319 and type "csc".'
The file may still exist but if you can open it with notepad, it will probably show just plain text of some errors. This is the indication that your compiler has been destroyed. At my office we have come up with a theory that a Windows update may be causing this because only a few machines have been affected, but I haven't read much online about it until now.
We fixed this by copying someone else's csc.exe into the C:\Windows\Microsoft.NET\Framework\v4.0.30319 directory and recompiling. Be sure to set the options on the file to read-only so this won't happen again. Good Luck!
The problems associated with csc.exe in Visual Studio 2012 can mostly be solved by repairing Visual Studio.
You need to repair Visual Studio. Go to Control Panel -> Programs. Then select your version of Visual Studio you are using and press "Change"(or right click it and press "Change"). When the setup appears, click "Repair".
I am on Visual Studio 2017 but this is the first google result that pops up for "csc.exe not found"
When I got this error I had to restart Visual Studio, being sure to select 'Run As Administrator'. Everything worked after that
I've faced this problem while i am trying to move Asp.Net Mvc Project from one computer to another ; error message was : The specified task executable location "c:\users\mypcname\documents\visual studio 2015\Projects\TestMVC\packages\Microsoft.Net.Compilers.1.0.0\build\..\tools\csc.exe" is invalid.
I solved this by
Creating new Mvc Project ;
going to that folder \Microsoft.Net.Compilers.1.0.0\build..\tools
and Copied the csc.exe file to my Projets >> \Microsoft.Net.Compilers.1.0.0\build..\tools\
i think when i was copying the project from the original Computer i left that csc.exe file in the specified folder.
Hope this will help someone.
Check your solution properties (right-click on Solution and select 'Properties') and make sure that the 'platform' field (Configuration Properties) is set correctly.
I think this problem is caused due to improper PC clean up. I was running Quick Heal PCTuner 3.0 software on a 64-bit windows 7 machine but suddenly due to loss of power my machine was shut down then when i opened it again I was getting this problem in VS 2013. Even TortoiseSVN checkout was not working and throwing internal error and something like corrupted disk also was shown when trying to delete some files on the harddisk.
I ran the PC Tuner again doing the Disk, Registry and traces clean up and it got fixed. maybe this problem may occur due to other cases also but is mostly related to the system's files In my case this is the fix
Regards.
in my case helped (I had .net framework 4.5.1 and vs c# 2010 express):
download the newest .net framework and run repair
On Visual Studio 2013, the same problem solved by doing this for me:
Right click the solution and open Configuration Manager. For the project(you may see at least one there), I've changed the Platform from Any CPU to x86 for the project that may causing the problem.
I've tried to delete and move csc.exe file but it doesn't do anything.
Then simply I upgrade .net version and than downgrade (returned to its original state) and it works.
I solved my problem by copying the whole folder containing my visual studio solution
From C:\Users\me\Google Drive...
To: C:\Users\me\OneDrive...

Categories