IL offsets missing when silverlight assembly is co

2019-02-07 02:16发布

问题:

I followed these instructions to add IL offsets to Silverlight stack traces. This works great when building in DEBUG mode however our production/qa build process compiles everything using RELEASE mode which seems to loose the IL offset information. In release mode all the IL offsets end up being "0xffffffff". Using reflector to compare the debug/release assemblies I noticed the DebuggableAttribute was used differently.

DEBUG build:

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: ComVisible(false)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.EnableEditAndContinue | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.Default)]
[assembly: AssemblyConfiguration("Debug")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows=true)]
[assembly: Extension]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: CompilationRelaxations(8)]
[assembly: TargetFramework("Silverlight,Version=v5.0", FrameworkDisplayName="Silverlight 4")]
[assembly: AssemblyCopyright("Copyright @ Foo Company 2010-2012")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("Foo.Ria.Bar")]
[assembly: AssemblyCompany("Foo Company")]
[assembly: AssemblyProduct("Foo Product")]

vs RELEASE build:

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: ComVisible(false)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows=true)]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyTitle("Foo.Ria.Bar")]
[assembly: AssemblyTrademark("")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: CompilationRelaxations(8)]
[assembly: TargetFramework("Silverlight,Version=v5.0", FrameworkDisplayName="Silverlight 4")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyCompany("Foo Company")]
[assembly: AssemblyProduct("Foo Product")

MSDN says

The DebuggableAttribute class controls how the runtime treats code within the module. The runtime might track extra information about generated code, and it might disable certain optimizations based on the values contained within this attribute.

Does anyone have experience tweaking the DebuggableAttribute settings? Is there any workaround that doesn't involve disabling optimizations entirely (DebuggingModes.DisableOptimizations)?