Visual Studio compiles but the exe isn't there - windows

Source code that compiles fine on other peoples environments won't correctly work in my environment. When I do a rebuild the compile occurs but when visual studio goes to move the exe from /obj/debug/{solution} to /debug/{solution} it cannot find the exe in the /obj/debug/{solution}. To make this even more crazy even after I reinstall visual studio it doesn't work. On other people environments it works find. Please note that this is a windows mobile 6, compact framework 3.5 project, Visual C++ project.
EDIT: Visual Studio 2008 is being used.
EDIT2: After looking at the logs again come to find out it says it is compiling but it isn't really compiling. Interesting enough it doesn't throw any errors until it tries to link the code. When it goes to link the object files, they aren't there and it fails.

I got TWO Release folders: one in the solution folder and one in the project folder. The former contains the .exe file, the latter does not.

In the solution properties page, check whether the path you are expecting the exe to be is same as the one specified in Linker -> Output file.
Another obvious mistake could be, check what build configuration you are building. You might be doing a release build and expecting a debug executable file :) I have done this a few times.

Maybe VS creates the exe, and before it tries to move it to the final destination your virus scanner grabs it and removes it, or moves it to a save location.

I just wanted to chime in and ask: have you looked for the *.exe file name from the directories above? What I found in my case was it was writing to the directory right above the /release subdirectory. Not sure how I missed that detail, but I did! I suppose it never occurred to me earlier because I saw the buildlog.htm being written to the /release subdirectory, and the very existence of the directory itself. In my case it was compiling, linking, etc. I just wasn't able to see the *.exe in that /release subdirectory.

There are two subtly different paths. I was looking here, which doesn't exist:
C:\Users\james\source\repos\CppHelloWorld\Release\CppHelloWorld.exe
The actual exe is here - note the path contains the x64 platform that it was built for:
C:\Users\james\source\repos\CppHelloWorld\x64\Release\CppHelloWorld.exe
In general, the path seems to be:
$PROJECT_PATH\$PROJECT_NAME\$PLATFORM\$CONFIGURATION\$PROJECT_NAME.exe

If the exact same solution works on other machines, then it's an environment problem and no amount of looking at the project, linker, etc is going to resolve this. What is different about the environments? Are the same service packs and QFE's applied for not just Studio, but also the OS? Is there a difference in processors (64/32-bit)? Are your permissions the same? Do you have the same SDKs installed?
I'd agree with Shahi that just trying to build a "hello world" app against the same SDK and see if it will compile is valuable info.

I had exactly the same problem. Just close Visual Studio and reopen it again (basically restart it) and it should work.

In my case, my network security team released an unannounced security update that preventing me from creating any .exe files. I figured that out at midday after trying all the solutions (+ more) here.

Perhaps you do not have write permission to the output folder? If you are running on Vista/7, is your Visual Studio running as elevated?

I've found this to be random for myself in now VS2016. My work around has been to just create another project and copy the contents from the one with out the .exe to the new one. For some reason the new one normally will have the proper .exe and location needed. While this isn't a complete solution at least it's been working for me for the time being.

It happened with me today:
TL;DR; You might be using some C# code in your project who belong to a language version which is not supported by the .NET Framework version targeted by your project
Details:
I had two projects in my solution. One project was already existing. I added a new project targeting most recent .NET Framework v4.6.1 supported by Visual Studio(VS) 2017 class library project template. I used some C# language features which is present in C# v7.0. In such a case, VS can compile the project but can't create the output in bin directory.
Eventually I had to merge the new project code files into the existing old project which was targeting .NET Framework v4.5.1.
So I changed the target Framework version to the latest .NET Framework v4.6.1 for the existing projects also. Then the old project also started supporting my newly pasted C# language features.

In my case, the error appeared after I cloned my solution on a new machine.
I did not realise that the newly-cloned solution had AnyCPU set by default, when in reality my solution only supported x64. The compiler, however, did not return any error.
What pointed me in the right direction was the Output log, highlighted that of the 4 projects my solution was composed of, one of them was always skipped, i.e. only 3 were actually compiled. Scrolling up a bit the log, I noticed some message similar to MSIL mismatch between CPU versions.
Switching from AnyCPU to x64 solved the error for me.
(I then deleted the AnyCPU option from the Configuration Manager to avoid this issue in the future)

If you create a new "hello world" WM project, does it work?
If so, you can compare the solution files to check for differences that can cause this.

As far as I could tell, you need to "Save All" before building.

Related

Installing a C# library in Visual Studio and using it on unity

I'm a bit of a noob on that topic so I'm searching for help. I need to install this library (https://github.com/twcclegg/libphonenumber-csharp) for a unity project where I need to check phone numbers.
But as I always made simple games in unity I really don't know how to do that and I don't really know either what to search to find an answer.
If anyone of you knows how to do it, it will really make my day.
Thank you
Once do a build on a project you want to use in Unity, then find the DLL output from the build. I recommend you do Release Builds, but for now if you are not familiar with Visual Studio just use what you were able to build. If there are multiple directories then you only need one - the best one to use would be any labelled ".NET Standard" which it seems you have a .net standard 2.0 directory.
Go to your Unity project in the Assets folder, and if there isn't already a Plugins folder create one. Then in Assets/Plugins create a folder named whatever you want for the library - in this case PhoneNumber would be fine. So you would have Assets/Plugins/PhoneNumber and you would copy/paste the contents of your NetStandard2 folder there.
In the end you should have Assets/Plugins/PhoneNumber/PhoneNumber.dll
As soon as you have that dll, you can switch back to Unity and see if it worked by checking the Unity Console for any Errors. You might receive errors saying it could not load the DLL. Almost always if it can not load the DLL it is because of missing dependent DLLs - which is why I said to copy the entire folder contents inside the "NetStandard2" folder since it may contain more than just PhoneNumber.dll - it may have it's necessary dependent dlls also.
If not, you can read the error output and hopefully get a clue as to what dependent dlls are missing. You can also expand the Dependencies in Visual Studio.
Typically the DLL failing to be loaded in Unity is because of missing dependent DLLs. Expanding the Dependencies, which is found under the project name in the Solution Explorer window on the right side of Visual Studio, will show you what libraries it requires. Most of what you see under dependencies (if not all) will require a similarly named dll. Under the netstandard2.0 dependency I see System.Collections.Immutable - so you may need a System.Collections.Immutable.dll which should (usually) be in the output folder when you build the project. You would also need that dll in Unity in your PhoneNumber folder along with PhoneNumber.dll

VS2010 Build Exception caused by ReSharper; SetEnvironmentVariable task not found

I've had a problem with my Windows 7 after an update, neither Safe Mode nor Recovery Mode could resolve the problem. I was forced to reinstall Windows completely. To develop on my projects I need Visual Studio 2010.
I always had ReSharper installed and got used to its features, so I installed it aswell.
Everything setup I tried building my solution but encountered a problem ...
(The underlined file can be found here: https://up.zone/aj)
After hours of trying to resolve the problems, I figgured out that ReSharper was the problem. I can build the solution perfectly fine without ReSharper installed. Having it installed, even if all features are turned off and the services are suspended, causes these errors in the picture above to show on build.
I managed to resolve two out of three errors by following the instructions of this Reddit user on his post: https://up.zone/ag
Now I am left with one more exception I cannot figgure out how to resolve. I couldn't really find anything helpful googling, which means you guys are my last hope. I really do not want to go back to developing without ReSharper.
This is the one:
Any idea?
Thank you!
Update 1
I figgured out that the problem must be in the NuGet.targets file, located in the .nuget folder in our solution.
I managed to find a workaround following the suggestion of this post, I am now able to build the solution without any errors.
To summarize, remove this line out of your *.csproj file
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
Although this works, I don't think this can be the solution. This line is there for a reason I assume. Anybody with a deep understanding of NuGet who might know how to properly resolve this problem?
Update 2
I found out that as soon as you reload your solution/project, the line gets added once again. Also, if you have certain dependencies nuget should download for you - it won't, because the line which makes that call and handles this got removed.
I'm now at a point where I know where the problem is but not why it is caused.
Does ReSharper change anything in the way NuGet behaves? As far as I can tell, nothing gets added or removed to or from the NuGet.targets file due to ReSharper.
There were one more report on this topic, at https://youtrack.jetbrains.com/issue/RSRP-462271 .
The best guess so far is that this is caused by two things happening at once: (a) using MSBuild tasks in C# source code form inside MSBuild XML files rather than DLLs and (b) having some of the MSBuild opensource DLLs shipped with the latest version of ReSharper for its own project file handling needs.
The source code gets compiled into a task DLL during an MSBuild run (not a much common thing to have; Roslyn would do this rather than ship a DLL? seriously?). When building from within Visual Studio (rather than with msbuild.exe), the in-process MSBuild instance is used, and it would run in the same appdomain as ReSharper, so it uses the common assembly reference resoluiton. If it's not too accurate, then it might accidentally pick the wrong DLL version by the short name, which would break the task compilation (that's a separate error, maybe cached away) and then result in the task-not-found error later at runtime (SetEnvironmentVariable task not found in here case).
I've tested on sample solutions with source code based tasks and could not get it broken. So trivial cases are OK. Never heard back from the original issue reporter, so there was no further progress.
Now I've got a hint that this is Visual Studio 10 (any other VS versions installed on that machine?) and maaaaybe it's Roslyn tasks. We might know for sure if you run MSBuild with more detailed logs (by setting the logging options at Tools | Options | Projects and Solutions | Build and Run | MSBuild project build output verbosity to at least Detailed) and building just the faulty project.
I'll also try this out with VS10 and update this reply with new data.

After a short while Visual Studio no longer accepts semicolon

When I start up Visual Studio 2013 everything works perfectly, then after 10-20 minutes it stops allowing me to type semicolon but everything else sill works. I can copy/paste semicolons from elsewhere in the source file, but this is a real pain.
It has been doing this for a few days. I didn't manually update anything recently.
I tried clearing the Resharper cache and even disabled Resharper altogether just in case but the problem keeps on happening.
Help!!!
I finally discovered what my problem is. I am writing a reusable library and want to build .Net 4.0 and .Net 4.5 versions from the same source code. I achieved this by creating two projects in the same folder that reference the same source files but are configured to target different frameworks, and use different bin and obj folders.
This setup seems to work really well for the most part, but it appears to really confuse the Visual Studio intellisense system because when you open a source file and edit it, Intellisense doesn't know whether to make suggestions from the .Net 4.0 or 4.5 framework because the source file belongs to both projects.
I solved my semicolon problem by unloading the .Net 4.5 project whilst editing and debugging the code, then reloading it when I want to make a release build.

Certain libraries force Visual Studio to compile F# project every single time

Certain nuget libraries seem to force my project to rebuild (as in run fsc.exe to produce a new binary) every single time I build the solution, even if nothing at all has changed. As soon as I delete the reference in the Visual Studio references tree, fsc.exe is no longer called until I actually make a change.
I don't actually need any code at all to reproduce this problem - an empty main function in a project referencing a problematic library will face this issue.
After some trial and error two nuget libraries which definitely cause this problem are:
FSharp.Actor-logary
Newtonsoft.Json.FSharp
but it may well apply to others.
I read in a comment elsewhere on stack overflow that type providers always force recompiles, is that true? My empty test project doesn't use type providers, but maybe these libraries do.
I am using Visual Studio 2013.
I think I've solved it: the problematic libraries have a last modified date of 15/12/2030
I've opened an issue on the project's GitHub page: https://github.com/logary/logary/issues/74
This has been solved when MSFT fixed their assembly-generation bug in mono.

The application was unable to start correctly (0xc000007b) when copying from one project to another

I'm using MS Visual studio 2010 and openCV 2.4.8.
I get the following error when I execute some project.
Suppose I have a solution which contains only 1 project. That was built by me.
And, I have one other solution created by someone else and there are 2 projects in it. Out of the 2 projects created by that person I chose one and I copied the required header files, cpp files, DLLS and everything and put them in my project.
Then I get the above error.
Both the projects works fine when executed separately. Have I made a mistake in copying ? Or else, is there something else behind this ?
to solve this problem you should copy the DLL files from the direction of opencv like C:\opencv\build\x64\vc12\bin to the debug or release file in the project files
The problem is due to 32/64-bit mismatches of various system dlls required by Visual studio. Somehow the dlls it needs got replaced by 64-bit versions that it couldn’t load.
Replacing the dlls mentioned below from a machine that is working, solves the problem:
c:\Windows\SysWOW64\msvcp100.dll
c:\Windows\SysWOW64\msvcp100d.dll
c:\Windows\SysWOW64\msvcr100.dll
c:\Windows\SysWOW64\msvcr100_clr0400.dll
c:\Windows\SysWOW64\msvcr100d.dll
The Application was unable to start correctly (0xc000007b). Click OK to close the application" when starting Visual Studio 2010
I've found another solution of this issue. In VS window you can just change the machine type from default 'Win32' to 64-bit (default 'x64').

Resources