4

When running a project in Test or Debug configuration in VB.NET using Visual Studio 2012, sometimes it gives the following error as the reason for "Build Failed"

Error 1 Could not copy the file "obj\Debug\MyProgram.exe" because it was not found. MyProgram

There are no issues with the code as it was just compiled seconds before this (sometimes I start the program again just to see how everything gets laid out visually and then go back to the code to make Location adjustments)

What I found is this. If I wait , when I go to test compile again -- it just magically starts working again -- Only to fail again later.

Sometimes, I can get 10-15 good compiles before it wigs out.

About my system configuration:

  • I do not have any other version of Visual Studio or standalone .NET language installed
  • The paths are set correctly (else it would never compile in the first place.. not just occassionaly fail)
  • The program can be a simple program with absolutely no code added (aka... New > WinForms Project > Compile)
  • The project, language (and all requirements), and project output path are on a local drive that is connected directly to the PC internally (using C:\code* for projects and the standard install location for Visual Studio 2012)

I checked the smart data and scanned my hard drive for any errors ... none ever encountered. The temperature of my system (CPU), and the drive is around 25-30 degrees C.

I am really baffled as to why this happens and at random. I have also tried completely clearing out the bin/ folder, and even Moving the project or repointing where the compiled output path is.

Deleting the .suo file helps sometimes, but not all the time.

I believe this is something that may be able to be tweaked in the UI somehow, however I do not know anything about manually linking and compiling programs.

Lastly -- it does not matter whether I run VS in "Administrator" mode (elevated privileges) or as a user.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Kraang Prime
  • 9,981
  • 10
  • 58
  • 124
  • may be related http://stackoverflow.com/q/18102859/1070452 see also: https://connect.microsoft.com/VisualStudio/feedback/details/793464/vs-2013-output-files-are-locked-and-prevents-further-compilation – Ňɏssa Pøngjǣrdenlarp Jul 22 '14 at 19:14
  • @Plutonix - I believe the error is similar for similar underlying reasons, however VB.NET doesn't give the intense compiler checkbox list options. Instead, it provides a space where one can type the command parameters. Problem, is the parameters for compiling a VB app are very different than a C# app. That being said, there is no "host" process running aside from the one for the WinForms project itself in the IDE (closing will kill VS). So the visual side is different, and it feels like I have no control over this happening. – Kraang Prime Jul 22 '14 at 19:56
  • 1
    @John Saunders - I added "(VB.NET)" as part of the question because the difference in compiler options is night/day from C#. While this may be a problem throughout VS languages, the solution for VB will be entirely different from a solution for C#. – Kraang Prime Jul 22 '14 at 20:00
  • @SanuelJackson: tags are good for that purpose – John Saunders Jul 22 '14 at 20:04
  • @JohnSaunders - Agreed, I just wanted to make sure this didn't end up as a "duplicate" of a C# question for the "same" problem. ^.^ . Thank you for the edits/corrections. – Kraang Prime Jul 22 '14 at 20:22
  • 1
    95% of the time this is your anti-malware software waking up with "Crikey, an executable file appeared from no-where!". They make the file invisible while they scan it, takes a random amount of time. You'll have to disable it or make an exclusion. – Hans Passant Jul 22 '14 at 22:19
  • @HansPassant - I will check my Antivirus history to see if any of these processes were blocked. I did notice VMWare (o.0) interfering with the launch process of Visual Studio itself, so I have since stopped that. Found VMWare is still hooking into and replacing the Visual Studio debugger (vsid.dll) ... this could be the problem. Digging deeper. – Kraang Prime Jul 22 '14 at 22:24
  • Woo .... it was VMWare -- Im willing to place bets that is 99% of the time the problem with compiling -- an injected VS debugger from third party software. Whoever wants to take cred for this, post it up as a solution (elim VMWare or maybe get creative), and I will flag it as answered. – Kraang Prime Jul 23 '14 at 02:11
  • >.< False alarm. Seems removing VMWare didn't correct the issue. Still looking for a solution for this one. – Kraang Prime Jul 23 '14 at 22:25
  • Wow, too late but interesting! I suppose you have tried to delete parts of your code and launch various times in order to understand witch external dependencies hook your solution. – Giulio Caccin Mar 02 '15 at 20:20
  • Update on this -- in Visual C# 2013, this doesn't seem to pose an issue -- only in VB.NET from tests. @Bujutsu - it can occur on a blank winforms project with nothing on the form. – Kraang Prime Mar 06 '15 at 07:25

2 Answers2

1

I faced this kind of problem because of my virus guard
blocked my application(but it is not have any harmful code :) )

  • exclude your project folder from virus guard
    or
  • simply disable it(not recommended)
Alupotha
  • 9,710
  • 4
  • 47
  • 48
  • This isn't the case. The problem occurs on a machine with nothing else but VS installed, as well as on my normal workstations. I have seen this happen only once when working with a c# project, but many times working in VB.NET. – Kraang Prime Apr 01 '15 at 15:05
1

Some methods that may help you

  • Have you tried to reinstall Visual Studio. If that does not work you may need to install some of Windows Updates, the compiler may be missing some essential libraries/references to compile your application.
  • Check your .Net Target Framework, setting your application to a new framework that you don't have installed can stop the application from compiling yet even stop it from being debugged, having a compiler that is to low, this may come with errors for the compiler but not for the IDE/Visual Studio to notice.
  • Try cleaning your project solution's output folder by right clicking your solution then try to rebuild your project/solution.
  • Check your compilation references in your project's properties, check if a reference added is not on your computer
  • Reinstall/Update .Net Framework, same here some requirements may be missing from your installation
  • Try installing a newer version of Visual Studio, try Vs2013 - this contains various improvements and fixes, Visual Studio 2015 is fast approaching, a recommendation install VS2015 when the full version gets released it will contain a lot of useful features for future .net programming.
  • Create an new Administrator account and Run VS with Administrator rights and try compiling then, this fixes some of problems in vs and other microsoft products, it might work here.
  • Install all of the .Net Frameworks from the lowest to current 4.5, this may help when some of the used references/libraries are not on your local hard drive.

if none of these methods work, i would not know of the problem one last thing you could try is installing Windows to another hard drive and try using that installation of windows and see what happens... Hope this helps.

Best regards!

Callum
  • 725
  • 6
  • 17
  • Thank you for the reply, however quite a bit of what you stated was already invalidated in my question. Will address in order of bullets using #'s. 1: If this were the case, it would NEVER compile, not just sometimes. Additionally, same issue occurs with VS2013, and VS2015. 2: Since I don't use any hokey-dokey hacks like 80% of github releases to make cross VS sln files, I do not have this issue. I ONLY see the frameworks I have installed. – Kraang Prime Apr 14 '15 at 10:46
  • 3: Deleting the "output" folder is impossible when this occurs as the vs_host.exe has the files locked which is the reason it gives an error on compiling. 4: If references were missing/etc -- it wouldn't compile in the first place. Please note, this is repeatable with a brand new project with NO CHANGES. 5: Again with the framework suggestions. This problem persists through formatting and cross-operating system. All required frameworks are forced to be installed before you can even continue to install VS – Kraang Prime Apr 14 '15 at 10:49
  • 6: VS2013, and VS2015 both experience this same phenomenon. Please note, this does NOT occur with "inferior" languages such as Delphi, VB6, etc. This is a problem with the whole crap debug process that VS has "vs_host.exe" or "vshost.exe" forget the name exactly. 7: Most machines run as admin anyway. This suggestion is m00t. 8: On operating systems such as Windows 8, a minimum framework comes pre-installed with pointers/embedded support for older versions such as 2.0. Mostly, they are "final" release versions. – Kraang Prime Apr 14 '15 at 10:52
  • Sorry i do not know the answer then, sorry i cannot be of service. Try sticking a bounty on this question, it will get it more views i hope. – Callum Apr 14 '15 at 23:16