【发布时间】:2014-05-22 22:02:07
【问题描述】:
我有一个大型 wp7 项目,在 wp7 上运行良好。在过去的几个星期里,我使用 wp8 设备进行调试(项目仍然是 wp7),它很好。
现在,我开始在 wp7 设备上对其进行测试,结果让我陷入了困境
System.Windows.Application.LoadComponent(this, new System.Uri("/MyApp;component/App.xaml", System.UriKind.Relative));
这个异常
System.Reflection.TargetInvocationException occurred
Message=TargetInvocationException
StackTrace:
at System.Reflection.RuntimeConstructorInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
at System.Reflection.ConstructorInfo.Invoke(Object[] parameters)
at MS.Internal.TypeProxy.<>c__DisplayClass30.<GetCreateObjectDelegate>b__2a()
at MS.Internal.TypeProxy.CreateInstance(UInt32 customTypeId)
at MS.Internal.XamlManagedRuntimeRPInvokes.CreateInstance(XamlTypeToken inXamlType, XamlQualifiedObject& newObject)
at MS.Internal.XcpImports.Application_LoadComponentNative(IntPtr pContext, IntPtr pComponent, UInt32 cUriStringLength, String uriString, UInt32 cXamlStrLength, Byte* pXamlStr, UInt32 cAssemblyStrLength, String assemblyStr)
at MS.Internal.XcpImports.Application_LoadComponent(IManagedPeerBase componentAsDO, String resourceLocator, UnmanagedMemoryStream stream, UInt32 numBytesToRead, String assemblyString)
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at MyApp.App.InitializeComponent()
at MyApp.App..ctor()
at System.Reflection.RuntimeConstructorInfo.InternalInvoke(RuntimeConstructorInfo rtci, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeConstructorInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
at System.Reflection.ConstructorInfo.Invoke(Object[] parameters)
at MS.Internal.TypeProxy.<>c__DisplayClass30.<GetCreateObjectDelegate>b__2a()
at MS.Internal.TypeProxy.CreateInstance(UInt32 customTypeId)
at MS.Internal.FrameworkCallbacks.CreateKnownObject(IntPtr nativeRootPeer, UInt32 customTypeId, String initializationString, IntPtr& nativePeer, UInt32 isCreatedByParser)
at MS.Internal.FrameworkCallbacks.CreateUnknownObject(String assemblyName, String typeName, IntPtr nativeRootPeer, String initializationString, UInt32& customTypeId, UInt32& coreTypeId, UInt32& typeFlags, IntPtr& nativePeer)
InnerException: System.MissingMethodException
Message=Could not load type 'System.Func`2' from assembly 'mscorlib, Version=3.7.0.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC'.
我改变了很多东西,所以我不知道去哪里找。
关于什么可能是原因的任何建议? System.Func'2 是什么?
编辑:再次澄清一下:项目始终针对 wp7。目前是:
EDIT2:输出为:
'TaskHost.exe' (Managed): Loaded 'System.Device.dll'
'TaskHost.exe' (Managed): Loaded 'Cimbalino.Phone.Toolkit.Background.dll'
'TaskHost.exe' (Managed): Loaded 'Cimbalino.Phone.Toolkit.dll'
'TaskHost.exe' (Managed): Loaded 'GalaSoft.MvvmLight.Extras.WP71.dll'
'TaskHost.exe' (Managed): Loaded 'System.Runtime.Serialization.dll'
也许有帮助? wp7上的Serialization.dll有问题吗?
EDIT3:我的系统配置:Windows 8.1 Pro、MSVS Pro 2012 Update 4。
【问题讨论】:
-
您无法在 WP7 上运行针对 WP8 的应用程序。您要么必须有两个针对 WP7 和 WP8 的单独项目,要么保留针对 WP7 的项目,这样两个操作系统都可以运行应用程序。
-
是wp7应用程序。刚刚编辑了问题以澄清这一点。
-
所以你把它定位到 WP8 并改回 WP7?
-
@CamBruce 不,我只是使用 WP8 设备进行测试。它是/一直是 wp7 项目。
-
如果您只是通过 wp7 应用程序进行部署,请尝试完全卸载该应用程序,在 VS 中运行“干净的解决方案”,然后重新部署。
标签: c# windows-phone-7 exception windows-phone-8