asp.net webconfig Debug=true and Solution Configuration as Debug [duplicate] - c#

Setting <compilation debug="true/false"> in Web.config seems to do things that you can also set in Visual Studio in Project properties, Build tab. Are they connected somehow? Does one of them takes precedence when compiling?

They are not connected. The compilation tag is ASP.NET only, while the project option one is for Windows Forms, console, WPF and so on.
ASP.NET compilation is so special, so you have to dive further to learn about every piece of it,
http://msdn.microsoft.com/en-us/library/ms178466.aspx

Set compilation debug="true" to insert debugging symbols into the compiled page. Because this affects performance, set this value to true only during development.

Related

Breakpoint Failed to Bind - Visual Studio 2015

I just upgraded from Visual Studio 2013 to 2015 and now I am having trouble with breakpoints.
It's a hit or a miss where break points will actually work and if I set one while debugging I get the error:
The breakpoint failed to bind.
Any help would be appreciated. I am about ready to give up on 2015 and go back.
I had the same problem but a different solution.
Please note I updated to VS 2015 Update 1 and the problem is still there.
In previous edition of VS starting debug automatically triggered a build in debug mode. But with VS2015 it does not.
So if your last build was in release mode, and you try debugging, breakpoint won't work.
You have to manually build in debug mode first, then start debugging.
I had the same problem.
I solved it disabling "Optimize code" option in project properties Build tab.
This may seem trivial, but after a lot of headscratching with the same issues as you mention, I found out that my build was set to "release" instead of "debug" when I tried debugging.. re-building the solution for "debug" fixed it, and I could set breakpoints as normal
I had a similar issue with breakpoints failing to bind, as well as certain local variables not evaluating in the Locals window. What finally fixed it was enabling the "Suppress JIT optimization on module load (Managed only)" option in the Options->Debug->General tab. Once I set that it was able to bind without issue.
I had this problem. I ran a performance profiling session which modified the Web.config file with settings for the performance monitor:
<appSettings>
<add key="Microsoft.VisualStudio.Enterprise.AspNetHelper.VsInstrLocation" value="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Team Tools\Performance Tools\vsinstr.exe"/>
</appSettings>
<compilation debug="true" targetFramework="4.5"
assemblyPostProcessorType="Microsoft.VisualStudio.Enterprise.Common.AspPerformanceInstrumenter, Microsoft.VisualStudio.Enterprise.AspNetHelper, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
...
</compilation>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.VisualStudio.Enterprise.AspNetHelper" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<codeBase version="16.0.0.0" href="file:///D:/Program%20Files%20(x86)/Microsoft%20Visual%20Studio/Shared/Common/VSPerfCollectionTools/vs2019/Microsoft.VisualStudio.Enterprise.AspNetHelper.DLL"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="VsWebSite.Interop" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<codeBase version="8.0.0.0" href="file:///D:/Program%20Files%20(x86)/Microsoft%20Visual%20Studio/Shared/Common/VSPerfCollectionTools/vs2019/VsWebSite.Interop.DLL"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
This broke my ability to stop at breakpoints. When I reverted back to the original Web.config (removed the Performance Profiler settings), the breakpoints started working again.
Change Release mode to Debug, In my case, this fixed my problem.
I had the same issue yesterday. I used the "Clean Solution" feature and it helped.
the solution is to disable the design optimization.
Project Properties> Build> Advanced Compile Options> Enable Optimizations
I run performance on my solution and that added this to my web.config
<compilation debug="true" targetFramework="4.5" assemblyPostProcessorType="Microsoft.VisualStudio.Enterprise.Common.AspPerformanceInstrumenter, Microsoft.VisualStudio.Enterprise.AspNetHelper, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
the assemblyPostProcessorType is the problem, I deleted it and that solved my problem
In case you are publishing your web-application check that Configuration is set to Debug(by default in debug configuration is set such that code not is optimized and symbol table is fully created).
I didn't change the 'optimize' setting, but based on other answers here, I
Set Solution Explorer to Show All Files for the project
Deleted the hidden bin and debug folders
Performed a 'Clean' on the project
Performed 'Rebuild' on the project
So far this has fixed it for me. Seems like updating to VS2015 Update 2 has borked a few things on my system.
STEP 1, Rule out the obvious:
Compile in Debug mode.
Try to Clean Solution before setting the breakpoint.
Go to the Debug folder, and delete [Your application].pdb file.
Then do a Build or Rebuild your application.
Go to the Debug folder and confirm you have a brand new [Your
application].pdb file.
Then try to set your break point.
STEP 2 For C++ projects:
Check the following project properties:
C++/General/Debug Information Format: Program Database.
C++/Optimization: Disabled.
C++/Code generation/Runtime library: Multi-threaded Debug.
Linker/Debugging/Generate Debug Info: Yes.
Linker/Debugging/Generate program database:
$(TargetDir)$(TargetName).pdb.
Linker/Manifest File/Generate Manifest: No.
Linker/Manifest File/Allow Isolation: No.
Linker/Embedded IDL/Ignore embedded IDL: Yes.
Do Step 1 Again
You can try adding __debugbreak(). This statement needs to go in your source file where you want to break.
STEP 2 For C# projects:
In the projects properties Build/General/Optimize code should be
disabled.
In the IDE settings Debug/Options and Settings/Debugging/General Suppress JIT
optimization on module load (Managed only): Enabled
Do Step 1 Again
Try opening your solution on another machines. If you can bind a breakpoint on a different machine this can mean that there is an issue with either your VS or your OS.
STEP 3, Make sure your VS is up-to-date:
There have been reports of issues like this in the VS2013 RTM as well as VS2015 Update 1 and Update2.
In VS go to Tools/Extensions & Updates/Updates/Product Updates and see what version you are running. If an update is needed it will appear there.
STEP 4, Make sure your OS is up-to-date:
Lastly, if your running a Win 10 OS, there was a reported bug regarding this issue which existed in build 14251. This was resolved in build 14257 (and above).
I know this is an old post but in case all the other tricks above don't work for you make sure the image you are trying to debug is current. For some reason after publishing and transferring a .NET Core project to my Raspberry Pi 'unzip' on the RPi was not copying and overwriting some DLLs in the working directory. When I attached the debugger thinking everything was OK some breakpoints were getting hit, others were not and some others were giving me the "can't bind" error. Once I resolved the unzip issue all my breakpoints and symbols came back. I hope this helps.
I encountered the binding breakpoint errors today. And I've solved my problem doing belows.
If your all debug configurations aren't correct you can't fix the problem doing belows.
Clean Project
If the output path is different from bin folder, replace it to the bin folder(this is the most important rule)
Rebuild
Maybe this solution helps someone.
VS breakpoints cannot bind on async methods.
I had an App Dynamics agent installed that caused this. Remove that and you are good to go.
I had the same problem, but hadnt realised that "Debug" had changed to "Release" on the debug tool bar(usually directly under the menu). So I set it to "Debug" it worked.
The new Update for Microsoft Visual Studio 2015 Update 3 (KB3165756) has fixed the breakpoint issue for me where I'm trying to inspect the local variables in C# code embedded in cshtml files in ASP.NET Core applications.
I just ran into a similar problem and none of the answers here hit on the issue I was facing. Unlike in the question, though, I never receive any message saying there was a failure to bind. The breakpoint just never hits. Hopefully this is helpful to someone in the future banging their head on the wall with WCF.
TL/DR:
In the SOAP message there was a record with bad data caused the breakpoint not to get hit.
Full Story:
I have a WCF service based on WSDL from another team. Not my definition, no control over it... I receive messages from this other team through this service. In my case I receive messages, can log the message to the message log table in the database (which happens prior to my service method getting called), the service method is seemingly called (maybe it isn't), and the server responds with a 202 Accepted. Communication is working, except no data gets saved to the database during the method call.
Since the service returns a success response I ruled out http and transport related issues.
So I fired up VS2015 to debug the service. The message in question is large but well within the limits of what I would expect. I put a breakpoint on the first line of the service method and sent the large message through, but the breakpoint never hit. I tried a smaller message that I knew worked on the very same run instance and the breakpoint was hit just fine. So everything in the configuration seemed fine. I thought maybe there was something in the message size.
I tried everything I could find - making sure I was in a debug config, clean and rebuild, manually attaching the debugger to the w3wp process (which VS already was), using Debugger.Break() instead of a breakpoint, setting multiple startup projects, unloading my test project so that the service project was the only one, updating .NET, restarting VS2015, rebooting, switching from Local IIS to IIS Express and back, recreating the service with the guaranteed latest WSDL.
Nothing mattered. The breakpoint was never hit.
I ended up having to weed out records in the large message one by one until I found one single record that had bad data. In my case it was one record that had no value for 2 DateTime fields. When I created a message that had just this one record in it and sent it, the breakpoint did not get hit. When I provided values for those 2 DateTime fields and sent the same (fixed) message in the breakpoint fired as expected.
I had every single CLR exception enabled, nothing fired other than missing .pbd files, which I didn't care about. WCF happily sent the request with a bad record through. I'm not saying that WCF shouldn't have sent it through based on the contracts, just that the bad record caused the breakpoint not to be hit.
I had to modify the web.config file to enable debugging. Change this:
<compilation debug="true" targetFramework="4.5.2" assemblyPostProcessorType="Microsoft.VisualStudio.Enterprise.Common.AspPerformanceInstrumenter, Microsoft.VisualStudio.Enterprise.AspNetHelper, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
to:
<compilation debug="true"/>
Clean the entire solution before trying any of the other solutions. After trying almost everything else said in earlier answers, and restarting visual studio several times, just cleaning the solution did the trick!
I tried everything suggested here. Eventually, I set the "Specific Page" in Project Properties -> Web to my local start URL, page and query parameter. Did a clean and rebuild in debug mode and it hit my breakpoint.
While this is a much later build (VS2017) I had this issue with C# projects. Tried cleaning, rebuilding, restarting visual studio, etc.
What fixed it was closing Visual Studio and deleting the .vs folder, which is a hidden folder located in the solution directory. Deleting the .vs folder should not cause you any problems, although you will need to reset your startup project.
In my case, there was a new web.config file created after I use Profiler. Restoring web.config to the previous version, resolved this issue. It was a VS2015 C# web application.
I looked over the previous answers and #Will's answear fixed the main issue i was having, the other being able to edit and continue but taking an closer look at the AssemblyInfo.cs file i found out some debugging features where disabled.
Then i ended up removing old debug attributes and adding the following that i took from another project
#if DEBUG
[assembly: System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute.DebuggingModes.DisableOptimizations | System.Diagnostics.DebuggableAttribute.DebuggingModes.EnableEditAndContinue | System.Diagnostics.DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | System.Diagnostics.DebuggableAttribute.DebuggingModes.Default)]
#endif
Yet i feel like this is not the best way of doing it.

ASP.net Website want debug to == false on IIS

Have tried adding this to web.config
<compilation debug="false" targetFramework="4.0">
</compilation>
but website still executes code in #if DEBUG when it shouldn't
*Wierdly the inline statement <% #if DEBUG %> on aspx files works but require also for .cs code.
NB development and live website on same box
#if directives in backend .cs files are handled by the C# compiler, not ASP.Net.
Set your project to the Release configuration so that that symbol is not defined when compiling the DLL in VS.
compilation debug element is not the same thing as DEBUG preprocessor directive.
You need to re-compile your website in Release mode.
What about binaries compiled with debug symbols?
One scenario that several people find very useful is to
compile/pre-compile an application or associated class libraries with
debug symbols so that more detailed stack trace and line error
messages can be retrieved from it when errors occur.
The good news is that you can do this without having the have the
switch enabled in production.
Specifically, you can use either a web deployment project or a web
application project to pre-compile the code for your site with debug
symbols, and then change the switch to
false right before you deploy the application on the server.
The debug symbols and metadata in the compiled assemblies will
increase the memory footprint of the application, but this can
sometimes be an ok trade-off for more detailed error messages.
http://weblogs.asp.net/scottgu/archive/2006/04/11/Don_1920_t-run-production-ASP.NET-Applications-with-debug_3D001D20_true_1D20_-enabled.aspx
Ensure the compile configuration to release as well. In Visual Studio, Build Menu > Configuration Manager and make sure "Release" is selected for all your assemblies, and/or is the active solution configuration.

DNN7 module cannot debug due to break point not hit

When i using the Default DNN7 create modules (DotNetNuke Compiled Module), i want try to debug on Page_load
CustomModuleController objCustomModules = new CustomModuleController();
and make and breakpoint on the line, or anyline on Page_load, it given the error.
The breakpoint will not currently be hit. No symbols have been loaded for this document.
I would recommend that you check out the templates at http://christoctemplate.codeplex.com the templates in the visual studio starter kit frankly don't work.
That being said, if you want to make sure that the current template will work, check the following
What is the build location of the DLL (right click on the project, choose properties, check the build tab)
Do you have debugging enabled in the web.config file?
Are you building in DEBUG or RELEASE mode?
What if you want to develop dynamic modules (non-compiled), in separate project, other than the website proj?
The Christoc Templates are all compiled, right?

Why the Web site project does not have release mode in config?

I'm currently working in the web site project.I want to build project in release mode, that unfortunately saw visual studio does not have release mode for build and only have debug mode.
in web application project we see two option in build debug and release.
I want to know why web site project have debug mode in build.I was read about debug and release mode building that release mode have optimize code and have less overhead.
You need to set release meod by right clicking solution > property> in dialog change it release mode or direclty from the rop of vidual studio set it for the release , see below image marked with red
In web site projects pages are compiled dynamically upon first request. It will compile without debugging symbols unless you specify otherwise in the config file.
You cant change it with configuration manager neither you see it in its options.
In your web config file find these options
<system.web>
...
<compilation debug="true">
...
</compilation>
</system.web>
Set true to false then it will publish in release mode.
Hope it helps

Conditional Compilation in Visual Studio(C#)

I am attempting to make it so that we can have our application to behave differently based on the presence of a preprocessor directive. I've read that you can create build configurations to define different preprocessor directives based on which build you do. Well, I am not seeing anything in Visual Studio to do this.. I know how to do it from the command line, but not how to do it within the automated environment of VS 2008.
Can someone tell me how to create a new build configuration which has preprocessor directives set in it?
Also, not sure if it has anything to do with it, but our project is an ASP.Net website
I do not even see a way to control the
DEBUG symbol, and it is an ASP.Net
website
Ok, there's the problem. The ASP.net web site option gives you a lot less control over builds, etc as it doesn't even use a project file.
If it is at all feasible for you to switch, switch over to an ASP.net web application. A web app will behave much more like a typical C# project (you have a project file, and the contents of the csproj file control what is in the app instead of just the directory structure, etc.
After you have converted, you should see the options that you are expecting.
Here's a link with directions for converting: How To Convert ASP.NET Website to ASP.NET Web Application
If you right-click the project and select "Properties", then select the Build tab, you can enter custom compilation symbols in "Conditional compilation symbols".
For example, if your code looks like this:
#if DEBUG
// do something
#else
// do something else
#end
You can set "DEBUG" as a Conditional compilation symbol.
You can set different values for different build configurations, by changing the "Configuration" drop-down.

Categories

Resources