在发布模式下编译Silverlight程序集时,IL偏移丢失 [英] IL offsets missing when silverlight assembly is compiled in release mode

查看:116
本文介绍了在发布模式下编译Silverlight程序集时,IL偏移丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了这些将IL偏移量添加到Silverlight堆栈跟踪的说明一个>。当在DEBUG模式下构建时,这很好用,但是我们的生产/质量构建过程使用RELEASE模式编译所有内容,这似乎丢失了IL偏移信息。在释放模式下,所有IL偏移最终都为​​ 0xffffffff。使用反射器比较调试/发布程序集,我注意到 DebuggableAttribute 的用法有所不同。

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.

调试版本:

[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构建:

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说


DebuggableAttribute 类控制运行时如何处理其中的代码模块。运行时可能会跟踪有关生成代码的额外信息,并且可能会基于此属性中包含的值禁用某些优化。

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.

任何人都有调整 DebuggableAttribute 设置?有没有不完全禁用优化的变通办法( DebuggingModes.DisableOptimizations )?

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

推荐答案

DebuggableAttribute 来控制JIT代码的生成。
实际上,在应该可调试且未进行某些优化的情况下,代码的生成方式有所不同。

The DebuggableAttribute is added by the compiler to control the JIT code generation. In fact, code gets generated differently when it is supposed to be debuggable and certain optimizations do not take place.

如果需要调整生成的程序集,您需要转储IL,更改属性,然后通过以下方式重新编译它: ildasm 创建一个人类可读的IL源,该源可以由对流文本编辑器更改,而 ilasm 用于重新编译。

If you need to tweak the assembly generated, you need to dump the IL, alter the attribute and recompile it back via: ildasm creates a human readable IL source that can be altered by a convetional text editor, while ilasm is used to recompile it back.

此过程可以自动化在您的构建中。只需记住,您搞砸了编译器生成的某些东西,并且不应该碰它。

This process can be automated in your build. Just remember that you are messing up with something generated by the compiler and not supposed to be touched.

重要提示:汇编需要再次签名,以防强名称和/

Important: the assembly needs to be signed again in case strong name and/ir authenticode is used.

这篇关于在发布模式下编译Silverlight程序集时,IL偏移丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆