1

I ran into an issue today where VB is behaving differently from C#. The issue is as follows.

Also note this is for .Net 4.0.

  • Both projects are set to build in release mode
  • Both projects are in the same solution
  • The solution is set to build in release
  • Both projects output to a Release folder in bin / obj

Everything seems to be okay except for one thing. When inspecting the files with a tool such as http://assemblyinformation.codeplex.com/ the VB projects show as Debug and the C# projects show as Release.

I tracked this down to a setting in the Advanced Compiler Options for the pdb files. If the debug info output for VB is set to anything other than none - then the project builds in debug mode (keep in mind it still outputs to the release folder). C# does not exhibit this behavior.

I did a blog post here to work around the issue - but would love to know the root cause if any one knows.

http://tsells.wordpress.com/2012/03/08/vb-projects-always-building-in-debug-mode/

Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575
tsells
  • 2,751
  • 1
  • 18
  • 20
  • I suspect your tool is reporting incorrect information. Do note that [whether or not debug info is emitted has absolutely nothing to do with whether the assembly is compiled in "Debug" or "Release" mode](http://stackoverflow.com/questions/5457095/release-generating-pdb-files-why/5457250#5457250). – Cody Gray - on strike Mar 09 '12 at 17:33
  • There were many discussions surrounding this in other areas. So how would you determine if it was debug or release mode just by examining the dll / executable? – tsells Mar 09 '12 at 18:05
  • Its also worth noting that the tool shows the project as being optimized - but debug mode. – tsells Mar 09 '12 at 18:08
  • What does that *mean*? Optimized but debug mode? – Cody Gray - on strike Mar 09 '12 at 18:12
  • I did some research and this tool is using the DebuggableAttribute class and is referencing the IsJITTrackingEnabled. If it is enabled - it shows the assembly as debug mode. It is looking at the JITOptimized attribute on the debug class to tell if optimization is enabled. http://msdn.microsoft.com/en-us/library/system.diagnostics.debuggableattribute.isjittrackingenabled(v=vs.80).aspx – tsells Mar 09 '12 at 18:17
  • I don't think the tool is wrong. Note that with the same settings - C# projects still show in release mode. This is isolated to VB only. – tsells Mar 09 '12 at 18:18

0 Answers0