Silverlight 和 Windows Phone 7 支持模块初始值设定项吗?
如果您愿意操作 IL .net 支持模块初始值设定项
http ://blogs.msdn.com/b/junfeng/archive/2005/11/19/494914.aspx
http://tech.einaregilsson.com/2009/12/16/module-initializers-in-csharp/
Silverlight 和 Windows 中支持模块初始值设定项电话7?
If you are willing to manipulate IL .net supports Module Initializers
http://blogs.msdn.com/b/junfeng/archive/2005/11/19/494914.aspx
http://tech.einaregilsson.com/2009/12/16/module-initializers-in-csharp/
Are Module initializers supported in Silverlight and Windows Phone 7?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅 C++/CLI 支持模块初始值设定项。这只是间接的,它使用它们来启动 CRT 并初始化非托管变量和对象。你必须用 IL 继续写下去。我尝试过,它在 Silverlight 4 上工作得很好:
这是一个愚蠢的例子,模块初始值设定项设置了 Class1 的静态字段。然后,我在示例 Silverlight 应用程序中创建了 Class1 的实例,并使用调试器验证了该值。
这段完全相同的代码在 Windows Phone 模拟器中无法工作。我应该修改 TargetFrameworkAttribute,但实际上没有尝试这个。我怀疑这就是问题的根源。
Only C++/CLI supports a module initializer. And that's only indirectly, it uses them to get the CRT started and to get unmanaged variables and objects initialized. You have to write on in IL. I tried, it worked just fine on Silverlight 4:
Its a silly example, the module initializer sets a static field of Class1. I then created an instance of Class1 in a sample Silverlight app and verified the value with the debugger.
This exact same code did not work in the Windows Phone emulator. I should have modified the TargetFrameworkAttribute, did not actually try this. I doubt that it is the source of the problem.