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

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

问题描述

我按照 这些说明将 IL 偏移量添加到 Silverlight 堆栈跟踪.这在 DEBUG 模式下构建时非常有效,但是我们的生产/qa 构建过程使用 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 发布版本:

[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.

重要提示:程序集需要再次签名,以防使用强名称和/ir 验证码.

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

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

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