Release builds hang/crash, regardless of code - c#

For some reason I just started having an issue with my release builds.
I'm able to run any of my projects without issue from the debug builds, I can also run my release builds as long as I attach a debugger, but when I try to run the release builds on their own they either hang infinitely (The UI crashes, but I'm unable to stop the process with task manager), or they load up EXTREMELY slowly (I've only ever had them eventually load twice, and that was on a separate machine from my main PC).
I know I don't have any viruses or any other system issues (I take very good care of keeping my system extremely clean), and I've tried running the programs with AV disabled.
Nothing I do seems to make a difference, and the fact that debug builds of my projects perform exactly as expected leads me to believe somehow I've altered a setting in VS regarding how it builds releases or something similar.
Could this be the case? If so, how should I go about fixing it?
If you need any more information please let me know.
EDIT: Something else I've just noticed about this issue is, the only time I'm able to run any of the executables I've built is if they are in the bin\debug\ folder of my project. That includes copying the "release" build of my project into the debug folder. It then runs just fine. I've also tried building an installer for my project, and it also will only run while in the debug folder, and nowhere else on my system. Doesn't seem to matter whether it's a release or debug build, as long as it's in that folder.

I ended up doing a complete uninstall of Visual Studio Community 2015 and all of the runtimes/etc. that were installed on the same date as VS, and reinstalled the program.
I then deleted all of the debug/release builds for my project, cleaned the solution and rebuilt them.
So far everything seems to be working okay now.
I'm not sure what the issue was, but a fresh install seemed to fix it.

Related

Visual Studio 2017 outputting older build versions in bin/debug folder

When I build a C# program (this has been going on for several different solutions/projects I have been working on) in Visual Studio 2017, the new, updated code will build and run in debug mode (and run correctly).
However, the application that Visual Studio has been outputting when I build/debug them has been remaining with the original, first version of code that I saved. When I choose the options to rebuild, it will update the time stamp on the application and .pdb files, but the application will perform the way it did in earlier code versions, not the most recent code version that was running problem when I ran debug mode immediately after pressing Ctrl + F5.
These are C# Console Apps with the .NET Framework 4.6.1, if that makes any difference. I checked the output folder, and it is indeed the desired folder and the one I have been looking in... so why is the time stamp updating on the application (.exe file) that it outputs, but not the code itself? What am I missing?
When I run into strange things like this in Visual Studio, the first thing that usually works is to clean the project and rebuild. If that doesn't work, I'll close Visual Studio, re-launch, then clean and rebuild again. If that doesn't work, I would start looking into any extensions you have installed that might be getting in the way of your build process.
Further, you can look into logging the extensions activity to help troubleshoot if there are issue there. See the following article:
https://blogs.msdn.microsoft.com/visualstudio/2010/02/24/troubleshooting-extensions-with-the-activity-log/
You may have already tried this, but since it wasn't mentioned I thought I'd provide it for others in a similar situation.
Two possible reasons:
(1) Your project was not recompiled during debugging. Please enable Edit and Continue under TOOLS->Options->Debugging.
(2) Visual Studio has a concept of incremental build. If you have a solution with two or much more projects and if you change source code in only one of the two projects, the "Build" command will compile only the modified project. But the "Rebuild" command, on the other hand, it will recompile all projects in this solution.

Program doesn't work outside Visual Studio

I use unmanaged dll with P/Invoke in this app, and I always tested it inside Visual Studio (with debug mode on x86 CPU because the dlls are only x86), and it works just fine. But when I just start the exe manually after some time (probably at the first operation with those dlls, but I don't know exactly) it says the exe has stopped working, and it starts checking for solution (I use Visual Studio 2013 on Windows 8.1, if that matters). I tried to add the dlls to the project as existing item, but that doesn't help. Also I know, that it's not because it can't find those dlls, cause if I delete them, it doesn't crash, just freeze without any error message. Shouldn't it work the same from Visual Studio as manually started?
There is also a weird bug when I run from Visual Studio: everything's work fine, but sometimes Visual Studio just suddenly stops debugging, as if the program were closed and the GUI of my app freezes, and I can only close it by closing Visual Studio (as I close it, the GUI disappears). Maybe it's a totally different problem, but it can be connected.
Edit:
Here's the project on github, if somebody could check it:
https://github.com/geiszla/CycriptGUI
Some news: If I run it with Ctrl+F5 it also crashes. What's the difference between F5 and Ctrl+F5, that can cause this problem?
Searched all over Google with no real simple answers. Here it is folks(at least it worked for me and is simple):
When you run the console app in Visual Studio, look at the output window at the bottom, get the location of the ..\bin\Debug\*.exe
Copy the *.exe and the *.config to your desired folder, run it, it should work the same way in Visual Studio.
Thanks for every help, my problem was solved: I called an unmanaged function with only 2 parameters, while it had 3. However I still don't understand why it worked with debugging mode, and not without debugging.

Code 'ghosts' in C#

The problem I have run into twice now is that my program seems to be running code that no longer exists. I figure that some old version is stuck some how but have no idea how to get the compiler to run the updated code I've written.
The way I have spotted the problem is by observing that bit maps I've loaded keep getting drawn even after I've removed instructions to do so. The problem persists even after removing every reference to the image in question, content load lines included.
The first time this happened restarting the compiler didn't fix the problem but restarting the computer did. Now the problem has persisted after a full shutdown.
I m using ms C# 2008 express edition if that has any bearing.
My first thought would be that the build is failing and that Visual Studio is running the old version. I don't have VS 2008, but in VS 2010 the option to change this option is in Tools->Options->Projects and Solutions->Build and Run.
You have to figure out where the mismatch is coming from.
What happens when you run the .exe from outside VS? What about from inside VS? Can you verify that after a build, the binary you're executing has an updated timestamp? Is the stale code in a .dll where the new version isn't getting pulled in?
In my experience this happens when configuration profile is changed from debug. For instance if I am running the debug profile, it works. Then I change to the QA profile and make changes and then build the new assemblies. The assemblies are built to a directory called "QA" however, when I debug through visual studio it runs the code from the debug profile. I can remove references, recompile the code, visual studio will still run from the debug profile. It appears that none of the changes I made are in the code. When in reality I'm inadvertently running a old build.

WPF DotNET Application will run in debug mode, but .EXE will not run

I wrote a WPF application in C# using VS 2010. The application will run fine in debug mode using Visual Studio, but when I go to run the .EXE from the bin\release folder, nothing happens. I do not get any error messages from windows and there are no errors or warnings in VS. I have tried to build, rebuild and clean the solution (in every possible order) with no luck. My solution contains 2 projects, both of which use .NET 4.0 framework, and I have .NET 4.0 installed on my PC. I have tried on both XP and Win7 and still nothing.
I also just noticed that the output from Debug when I run the application in debug mode says: "Cannot find or open the PDB file" after each .Dll it loads.
I am compiling to the Release folder every time, but i did try changing it to the debug folder and clean/rebuild just to see if that would make a difference, and it didnt, so I changed it back, tried it again, and still nothing.
Any Ideas?
Here are a couple of ideas that come to mind
If you are on a x64 machine, try changing the application from being AnyCPU to x86. This the mode that applications default to in debug mode and it's possible an issue running in x64 is causing a problem in release builds
Possible the Release binaries are out of date. Delete the binaries from the Release folder, rebuild and run the newly generated runs
Run the release build under the debugger in Visual Studio and see if it till crashes
I was experiencing the above issue too, however none of the other solutions worked for me.
My Application logs in Event Viewer listed event ids 1018 and 1022. This appeared to be bizarrely related to an ASP.NET 2.0 dll (bizarre; as this was a blank WPF project only). The logs contained messages like this:
Windows cannot open the 64-bit extensible counter DLL
ASP.NET_64_2.0.50727 in a 32-bit environment
In the end it turned out to be resolved when I disabled my anti-virus. I had read that this resolution worked for someone with McAfee; and it also worked for my environment, which has Avast.
I assume you tried on a machine that doesn't have visual studio installed, and also none of the components you are using for development.
You have only one option: start the application with a debugger on the machine that causes problems and check for exceptions there. (use WinDBG for example - it's light and easy).
This looks like a problem with missing dependencies, but might be something else also.
The Debugging Labs should give you enough information on how to use windbg to find your problem:
.NET Debugging labs
Also use this:
WinDBG Cheat Sheet
(JaredPar) answer looks right (x64), but if not try right clicking on the EXE and running in admin mode for win 7.
I had a very similar issue.
Check out this setting on your App Pool entry:
Go to Advanced Settings.
Change 'Enable 32-bit Applications' to 'TRUE'.
This worked for me!
I'm going to go with a wild guess that:
Either you have some odd corruption in your .NET Framework installation
There is some debug/release-specific code using #if DEBUG or the such that is substantially different to cause issues.
You have not compiled recently into Release yet (Try changing it to Release before compiling your latest code and make sure you get no errors).
Those are the only things I can think of off the top of my head.
I had run into a similar issue, I was missing a custom folder in the release mode I was referencing in the constructor. Adding the folder to the release fixed the problem.

When I run a unit test visual studio crashed

When I am working with a VS 2008 Team System solution with a very large number of projects VS crashes on me all the time.
Strange thing is that the other developers don't have the same problem and it has only been a problem for me the last couple of days. Don't know suddelny why i'm having this problem.
When i run a unit test it crashes and when i get rid of a bunch of projest from the solution and run the same unit test it's doesn't crash.
It has nothing to do with add ins, VS settings, the machine spec and i already tried reinstalled VS. It has something to do with VS running out of memory or something
Here are the steps i took so fare:
Reinstalled VS then rebuilt the solution, deleted all VS files like the .user file and deleted all add ins.
I also increaed my virtual memory. My machine isn't running at 100% CPU or 100% RAM at the time and there is no usful messages in the event log.
It crashes when i do anything really except opening and closing files, like running a unit test or going into debug mode
any suggestions?
Your question doesn't have a lot of info - no error messages, no steps you take to get the crash, no steps you've taken to troubleshoot or what the outcome was, not even what you mean by "very large number of projects"...
So when you say "it has nothing to do with add ins, VS settings.." it's hard to accept that on faith, (or even help you at all honestly).
First thing I would do would be to reset all settings with Tools | Import and Export settings..., then "Reset all settings". I would make sure all extensions are uninstalled (not just disabled. And I would delete my .suo file (been burned by that before).
If none of that works, a repair install or uninstall/reinstall would be next. I'd also look at any new applications or service packs I've installed over the last few days.
When using VS 2008 with ReSharper (5.1, 6.0 or 6.1) I had the same problem. After uninstalling a seperate NUnit installation the crashes disappeared for me.

Categories