Cannot build my class library on Release, only on Debug - c#

I've right clicked the project in Visual Studio and selected properties. Then I changed the Build configuration to Release. But even after hitting Control+Shift+B to build my library, I still find the /Release/ folder empty.
If I close the properties window and re open it, I see the option has switched back to Active(debug)
What am I missing?

You haven't actually changed to make the Release configuration active - you've just gone to the properties for the Release configuration.
The "active configuration" is normally in a toolbar just under the main menu - look for "Debug" there and change it to "Release" like this:
Or go to "Build > Configuration Manager" and change the active release there.

Open your Output Window of Visual Studio and after successful build ensure that your project's DLL is created in Release folder, with actual complete path provided, where you are checking for binary presence.
If it's ok, check if your Console application doesn't have any post build event in it, which simply moves the binaries of DLL projects.
If it's not, try to not use Control+Shift+B combination, but simply make a RightCLick DLL project and make it Rebuild.
Hope this helps.

Related

How to rename "Primary output from MyProject (Active)" and .exe

I am brand new to building and deploying Windows Forms applications, so new that I'm not even sure "build" and "deploy" are the correct terms. I read this excellent guide to creating an installer for my application, and I mimicked it almost exactly.
I have a winform project UmfExtract and a setup project UmfExtractSetup that installs UmfExtract . After installation, however, on Windows 10, an icon appears at the top of the start menu, under Recently Added: "Shortcut to Primary output from UmfExtract (Active)." I want to rename that to just "Shortcut to UmfExtract" or just "UmfExtract." Additionally, in the installation directory, the .exe and the .exe.config are the same as the original name of my project when I first created it, PythonExecuter. How do I change PythonExecuter.exe to UmfExtract.exe? Elsewhere on the user's computer, the application is named correctly. On the desktop, the shortcut icon says "UmfExtract," which is correct.
In all my research on this, people have said to change the Assembly name. I have done that. The Assembly name is UmfExtract:
I looked into the Outputs property of the Primary output object:
The AssemblyTitle and AssemblyProduct in AssemblyInfo.cs have been changed to UmfExtract:
What else could I possibly be missing? Could I perhaps accidentally be installing an older build of my project? I right-click on each project in the Solution Explorer and click Build (while the Debug/Release drop down box in Visual Studio is set to Release), then I navigate to the Setup project on my local machine and go to \Release\UmfExtractSetup.msi. I imagine that .msi file is updated/overwritten to the new information each time I Build the projects. Could it be that I'm building wrong?
I'm not 100% sure what was wrong, but the problem has been fixed. I believe the error was in the build process. I believe I was installing an old build of the project. I clicked Build > Clean Solution from the menu bar, then Build > Build Solution. I also right-clicked the UmfExtract project and then clicked Clean, then Build, and I also right-clicked the UmfExtractSetup project and then clicked Build (there was no Clean option in the right-click menu for the Setup project).

Visual Studio project not building when I click debug or press F5

VS2010 c#, winforms project.
It does not build automatically when I click on debug or press f5. If I manually build the project before I debug, it compiles and changes are picked up.
My other projects all work as expected. Why doesn't it build automatically?
Right-click the Solution (not project) in the Solution Explorer and select Configuration Manager. Check if Build is turn off for the current configuration.
Check your settings in Tools->Options.
Go to the projects and Solutions area, Build and Run page.
There is a setting "On Run, when projects are out of date:" Make sure this is set to 'Always build.'
I ran into this same issue and I did the following:
Run Build Clean
Close the solution
Delete any .suo and .user settings files
Delete any .ncb files
Open the solution again
Unload the project
Reload the project
Make sure the project is set as startup again
Debug away!
You may be able to only do steps 6-9 but I don't know how to get back in that state.
Because my project was independend from other projects by using prism I had to uncheck 'Only build startup projects and dependencies on Run' in Tools->Options->Projects and Solutions->Build and Run.
When you work on a dependency
In my case, I am working on a library used by an executable.
It was necessary to say to the solution to include the dependency of the library in the executable project solution to build the executable code and the library code before launching the debugging:
Tools Menu, click on Options. Go to "Projects and Solutions/Build and Run", "On Run, when projects are out of date" needs to be on "Always build".
Right-click the Solution (not project) in the Solution Explorer and select "Project Dependencies". Check the boxes of dependencies "Lib1" and "Lib2".
Just in case someone else runs into the same problem as I did: for me it turned out to be a setting in my web.config as follows:
<httpRuntime fcnMode="Disabled" targetFramework="4.5" maxRequestLength="40960" executionTimeout="1200" requestValidationMode="2.0" />
What this guy does is he disables File Change Notification, which is used to restart the application domain when a change is detected in critical files e.g. anything in the bin or .config files. Without fcn, I would make code changes, press F5 and still see the old code, and all breakpoints would be whited out because the source was different to what IISExpress was serving up.
I had a similar situation with multiple projects in a solution in Visual Studio 2013. One of the projects that the Startup project uses was not building when I clicked the Run button. I had to right-click on the Startup project and select "Build Dependencies" and check the project that wasn't building in there.
Was scratching my head on this for a while, turns out our office's Folder Redirection configuration (e.g. My Documents to point to a Network location) did not integrate well with VS.

Why are my binaries not placed in the /bin/release folder when I build a Windows Service in C#?

I am new to C# and VS 2010, and am following an online guide to creating a C# Windows Service in Visual Studio 2010.
When I try and build the application however, I don't get any files created under the /bin/release folder.
I do get files under the /bin/Debug folder.
I have tried all the build configurations e.g Active, DEBUG, Release, All but nothing changes.
I have tried closing the solution down and restarting etc.
I have also experienced this same problem on a number of other projects which have been C# console apps.
The /bin/release folder exists (as I had to create it by hand) and I have checked the output path in the properties tab to ensure the release configuration is targeted to that folder.
I asked our "C# guru" at work and he didn't have a clue. Does anyone know what could be causing this?
Most likely, you are only configuring the Release build, not actually building the project in Release mode.
Simply select "Release" mode from the drop down box in the toolbar, as shown in pic below:
or you can do the same thing from your project's Properties:
Then when you will build the project (Ctrl+Shift+B), it will build in Release mode and place the output in the folder you have configured in Project properties. (Usually this is bin/release.)
If you still don't see files in the release folder then as suggested by Gishu in the comments, check the Output Window while the build is in progress to see where the binaries are actually being created.
I witnessed the same problem.Even when I had the configuration as Release as shown above,VS will some how ignore it and as I can see from the output window,it puts it in the Debug folder.
Trick that worked for me:
1] Go to Build Tab on VS.
2] Click Configuration manager.
3] Under the drop down both at active solution configuration and the project specific configuration, select release.
4] Check the project properties just to make sure. Then build it.I the release folder the required files.
Accept the answer if it helps.

Built with optimizations enabled or without debug information

I'm currently trying to find out why my InjectableAttributes never get to the filter part.
Therefor I linked in the source project directly so I could easily put breakpoints etc.
When I build however I get the following message:
The following module was built either with optimizations enabled or without debug information:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\[a bunch of randomly named directories]\assembly\[more random names]\MvcTurbine.Web.DLL]
To debug this module, change its project build configuration to Debug mode. To suppress this message, disable the 'Warn if no user code on launch' debugger option.
I checked the project's properties. It's configuration is set to "Active(Debug)" and the "Optimize code" check box is unchecked.
UPDATE
I checked again if I didn't by accident include the file rather then the project, but the references seem correct.
Just to be sure I also removed all existing bins so that all libraries are definitely rebuild somewhere, but to no avail.
UPDATE
In the advanced Build window the Debug output is set to Full and all options are identical to projects that are building debug info.
The config manager shows that the project is being built and has the exact same settings as all the other options.
UPDATE
In the Debug->Windows-Modules window the symbol status for the turbine library is PDB file does not match image I removed all corresponding pdb files on my entire system to make sure it gets re-generated, but to no avail.
To make sure I also searched for the dll on my entire system and removed them. Nothing.
What can be preventing VS from creating debug information?
I've just experienced the same problem this morning, using VS2010. I solved it by deleting all the build artefacts, e.g. executables, libraries, PDBs, etc. This was in \bin\Debug, \bin\Release, \obj\Debug, and \obj\Release (including sub-folders). Then I recompiled the debug configuration, and was back in business.
Check that debug info is being generated for the project. You can do this by opening the Build tab on the Project Properties page and clicking the "Advanced..." button. Check the "Debug Info" setting. See this MSDN article for an explanation of what each option means.
If that doesn't solve it, check that the MvcTurbine project is actually being built (Build -> Configuration Manager).
It sounds like you've referenced the MvcTurbine.Web.DLL file rather than the MvcTurbine project. Try removing the reference and re-adding it as a project reference.
Update Are you sure the DLL isn't coming from the GAC? Do Debug->Windows->Modules when the app is running and check the Path column.

How do I remedy "The breakpoint will not currently be hit. No symbols have been loaded for this document." warning?

A C# desktop application (on the Visual Studio Express edition) worked, but then it didn't work 5 seconds later.
I tried the following:
Ensure debug configuration, debug flag, and full debug information are set on all assemblies.
Delete all bin and obj folders and all DLL files related to the project from my entire machine.
Recreate projects causing the problem from scratch.
Reboot.
I have two Windows Forms projects in the solution. One of them loads the debug information, one doesn't. They both refer to the assembly I'm trying to get debug information on in exactly the same way in the project file. Any ideas?
I want to add here, mostly for myself when I come back to review this question, that symbols are not loaded until the assembly is loaded, and the assembly is not loaded until it is needed. If the breakpoint is in a library that is only used in one function in your main assembly, the symbols will not be loaded (and it will show the breakpoint as not being hit) until that function is called.
Start debugging, as soon as you've arrived at a breakpoint or used Debug > Break All, use Debug > Windows > Modules. You'll see a list of all the assemblies that are loaded into the process. Locate the one you want to get debug info for. Right-click it and select Symbol Load Information. You'll get a dialog that lists all the directories where it looked for the .pdb file for the assembly. Verify that list against the actual .pdb location. Make sure it doesn't find an old one.
In normal projects, the assembly and its .pdb file should always have been copied by the IDE into the same folder as your .exe, i.e. the bin\Debug folder of your project. Make sure you remove one from the GAC if you've been playing with it.
Check to make sure that you are not in release but in Debug.
When in debug:
First try rebuilding your project by right mouse click the project > Rebuild
If that doesn't work, try a clean of the project (right mouse click on the project > clean)
If that didn't work check this:
Right mouse click your project
Select [Properties]
Select the [Build] tab
Make sure [Define DEBUG constant] and [Define TRACE constant] are checked
Make sure [Optimize Code] is unchecked
Click the [Advanced] button at the bottom of the Build tabpage
Make sure that [Debug Info:] is set to [full]
Click [OK] and rebuild the project ;-)
(step 7 generates the .pdb files, these are the debugging symbols)
Uncheck the "Enable Just My Code" option in the
Tools/Options/Debugging/General
Just something simple to try - you may have tried it already.
Right click the Solution in solution explorer, click "clean solution", this deletes all the compiled and temporary files associated with a solution.
Do a rebuild of the solution and try to debug again.
I've also had troubles with breakpoints multiple projects in a solution - some compiled as x86, some as x64.
The selected answer led me to fix my problem. But I need to do a few things more:
Even with "Debug" selected in the dropdown:
And in the project Properties > Build:
The Visual Studio was not loading symbols to a specific project. So in that dropdown I select "Configuration Manager" and saw that the settings to my web project was incorrect:
Then I set that to "Debug" and it started to generate the .pdb file.
BUT I need to manually copy the PDB and DLL and put in the folder that VS was looking (here is where the selected answer helped me):
Sometimes, even though it gives you this error, the Breakpoint still gets hit, so just ignore the error.
This happens fairly often in the Views of an MVC web app, i.e. .cshtml.
I was able to fix the error by simply setting the option in the 'Attach to Process' to 'Automatically determine the type of code to debug' option as shown in the attached screenshot.
Simply follow the steps below:
Go to Debug from the menu bar
Click on Attach to Process
Near the Attach to option, click on the Select button
The Select Code Type window will appear
Now select the option Automatically determine the type of code to debug and click the OK button.
Debug > Windows > Modules to see what modules were being loaded put me in the right direction.
In my case IIS Express seemed to be loading a different DLL from the temporary ASP.NET files.
The solution?
Browse to C:\Users\<YOUR USER>\AppData\Local\Temp\Temporary ASP.NET Files\vs
Delete everything in this directory!
Check if your .pbd file is missing in your bin/Debug folder. If it is then go to "Properties" of your project, selected "Build" and then "Advanced" at the bottom. Choose "full" under "Debug info" in the new window that appeared. This was my issue and solved it for me.
In my case "Optimize Code" was checked in my project properties. This caused VS to see my assembly as "not my code", and in turn, it did not load symbols for it.
The solution was to uncheck this.
Try running visual studio as an administrator within windows.
You need to enable "Generate debug info" in compiler settings
I tried everything mentioned above, but nothing worked.
[Clean solution, and check for PDB files etc.]
Even publishing the same solution did not resolve the issue.
Then I went to back to what I usually do to resolve (fool this stubborn Visual Studio)
All I did was to make a deliberate change in code and publish the solution.
Then I reverted the change and published again.
Voila [PDB files rid of evil spirits].. Not a smart resolution, but this did work.. :-|
We found the cause of our problem. This code was using the "CodeBehind" attribute in the Page directive of the .aspx file instead of the "CodeFile" attribute (ASP.NET 2.0 and beyond). After days of desperation, a simple search and replace solved the problem.
Option "Start debugging, Debug + Windows + Modules" does not exist in Microsoft Visual Studio Express 2013 edition.
Unchecking "Use Managed Compatibility Mode" in Tools Options Debugging fixes this.
Webapplications (IIS Express) only:
Rightclick IIS Express Tray and close the IIS.
Clean Solution
Clean solution and Rebuild
Check the configuration is set to Debug
Make sure that the PDB file is in the Debug folder it self
From Debug menu click Enable All Break points
Make sure you're in Debug and not is release by choosing debug in the dropdown menu like you can see in the picture below.
Then, try cleaning your project by clicking the right button in your mouse on the solution in the solution explorer window and choosing Clean solution.
Then rebuild your solution by clicking the right button in your mouse on the solution in the solution explorer window and choose Rebuild solution
Check are the following two setting the same in Visual Studio:
Right click test project, go to Properties, Build tab, and look at Platform target
Mine are all set to "Any CPU" so x64
On the Main Menu bar, go to Test, Test Settings, Default Processor Architecture
Mine was set to X86
Changing this to X64 to match above setting made the built in Visual Studio menu “Debug Test(s)” work and hit breakpoints that were previously ignored with the message “The breakpoint will not currently be hit. No symbols have been loaded for this document”.
Update:
For Visual Studio 2019 the menus have been moved around a bit:
I also had the same issue what I rebuild the whole solution (including refereced projects) in x86( or x64)
Even though I set all of my projects to x86 from Configuration Manager (Build->ConfigManager) some of my projects were not set to x86.
So Just to make sure right click on the project and follow
project -> properties -> Debug Tab, verify Configuration and Platform.
The .dll where I want to stop debugger and the associated .pdb files where copied near the .exe file. Those files had an older date so I thought they weren't updated in the runtime. I manually deleted them, Visual Studio create another pair AND put this new pair near the .exe. Now the breakpoint works!
Maybe Visual Studio cannot copy and REPLACE existing files (.dll and .pdb) near the .exe since there are another there. So if I deleted manually then VS could create new one near .exe.
I think that the root cause of the problem is that the Visual Studio use another file in runtime, no the file from the project, with the stop.
Instead of doing all these things just Close and reopen
Project Properties (then select your build config) > Build Tab > Advanced... > Debug Info (dropdown)
Set to 'all' or 'pdb-only' then rebuild
This took me a while tried other options above and for some strange reason debugging stopped working.
Tool -> Options -> Debugging -> General -> (untick) "Require source files to exactly match the original version" option
I was integrating a C# application with a static library using VS10 - which I'm new to. I wrote a managed code dll to interface them. I could set breakpoints everywhere but the static lib. I got the message described above - no symbols have been loaded for this document. I tried many of the suggestions above. I could see that the symbols weren't being loaded. I finally noticed a check box Configuration Debug, Enable unmanaged code debugging. That allowed me to set breakpoints in the static lib functions.
In my case, I was compiling a class library (DLL). No modules seem to be loaded in Debug -> Modules, so I couldn't even load the symbols manually.
My solution was to add this line to my code:
System.Diagnostics.Debugger.Launch();
Once this code is reached, an exception is triggered and .NET Framework shows a dialog box asking which Visual Studio (i.e. new instance of VS 2008, new instance of VS 2013, etc) you want to use to debug the program. You can choose the existing instance of VS with your project loaded. This will attach the process to your VS session and load all symbols, and now you can debug your project.
Of course, the compilation has to be done using the Debug configuration, not Release.
For an ASP.Net application, check the properties of the site, ASP.NET tab. Ensure that the correct ASP.NET version is selected.
I think the source if this error is, the debug symbols have a hard time surfacing to the solution after building for release.
I tried all the other answers -- generally, regenerating .pdb symbols or checking their location, cleaning and rebuilding project, ensuring active configuration is not Release etc.
What eventually worked for me is right-clicking on the project in solution explorer > Debug > Start new instance.
After trying a bunch of these, the thing that ultimately worked for me was this:
In Debug > Options > General, uncheck Enable Edit and Continue.
this happened to me after copy paste another webservice asmx file into an existing webservice, resulting in the same error when trying to debug the recently added service, to be able to debug I had to start without debug, then attach to the process. its weird but its the only way i found to be able to debug.

Categories