我试图在我的 Windows Phone 7 项目中使用 Unity 2.0 beta 2 for Silverlight,但我一直遇到这个崩溃:
Microsoft.Practices.Unity.Silverlight.dll!Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.DynamicMethodConstructorStrategy() + 0x1f 字节
Microsoft.Practices.Unity.Silverlight.dll!Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.DynamicMethodConstructorStrategy() + 0x1f 字节 mscorlib.dll!System.Reflection.RuntimeConstructorInfo.InternalInvoke(System.Reflection.RuntimeConstructorInfo rtci = {System.Reflection.RuntimeConstructorInfo} , System.Reflection.BindingFlags invokeAttr = Default, System.Reflection.Binder binder = null, object parameters = {object[0]}, System.Globalization.CultureInfoculture = null, bool isBinderDefault = false, System.Reflection.Assembly caller = null, bool verifyAccess = true, ref System.Threading.StackCrawlMark stackMark = LookForMyCaller) mscorlib.dll!System.Reflection.RuntimeConstructorInfo.InternalInvoke(object obj = null, System.Reflection.BindingFlags invokeAttr = Default, System.Reflection.Binder binder = null, object[] parameters = {object[0]}, System.Globalization .CultureInfo 文化 = null,参考 System.Threading.StackCrawlMark stackMark = LookForMyCaller) + 0x103 字节 mscorlib.dll!System.Activator.InternalCreateInstance(System.Type type = {Name = "DynamicMethodConstructorStrategy" FullName = "Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy"}, bool nonPublic = false, ref System.Threading.StackCrawlMark stackMark = LookForMyCaller) + 0xf0 字节 mscorlib.dll!System.Activator.CreateInstance() + 0xc 字节 Microsoft.Practices.Unity.Silverlight.dll!Microsoft.Practices.ObjectBuilder2.StagedStrategyChain.AddNew(Microsoft.Practices.Unity.ObjectBuilder.UnityBuildStage stage = Creation) + 0x1d 字节 Microsoft.Practices.Unity.Silverlight.dll!Microsoft.Practices.Unity.UnityDefaultStrategiesExtension.Initialize() + 0x6c 字节 Microsoft.Practices.Unity.Silverlight.dll!Microsoft.Practices.Unity.UnityContainerExtension.InitializeExtension(Microsoft.Practices.Unity.ExtensionContext context = {Microsoft.Practices.Unity.UnityContainer.ExtensionContextImpl}) + 0x31 字节 Microsoft.Practices.Unity.Silverlight.dll!Microsoft.Practices.Unity.UnityContainer.AddExtension(Microsoft.Practices.Unity.UnityContainerExtension 扩展 = {Microsoft.Practices.Unity.UnityDefaultStrategiesExtension}) + 0x1a 字节 Microsoft.Practices.Unity.Silverlight.dll!Microsoft.Practices.Unity.UnityContainer.UnityContainer() + 0xf 字节
以为我可以解决它,我尝试了几件事,但无济于事。
事实证明这是一个相当基本的问题,我假设 Windows Phone 7 是 Silverlight 3 + 其他一些东西是错误的。本页介绍Mobile Silverlight 和 Silverlight 3 之间的区别。
特别感兴趣的是:
Silverlight for Windows Phone 不支持 System.Reflection.Emit 命名空间。
这正是Unity在手机上崩溃的原因,DynamicMethodConstructorStrategy
类使用System.Reflection.Emit
相当广泛......
所以问题是,对于 Windows Phone 7,Unity 有什么替代品?