我有一个大型的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.
答案 0 :(得分:1)
好的,我已经设法解决了这个问题。问题在于Newtonsoft.Json库,声称当前版本(6.0.3)与wp7兼容,但实际上并非如此。
解决方案:回滚到5.0.8:
Install-Package Newtonsoft.Json -Version 5.0.8
答案 1 :(得分:0)
使用带有WP8目标平台的WP SDK 8.0在VS 2012中打开WP7应用程序后,您无法再使用此项目作为WP7项目。如果您想继续在VS 2012中开发新环境,则需要使用Target平台:WP 7.1。 请检查目标平台的设置。
如果您想支持WP 7操作系统,您需要维护两个不同的应用程序并将它们独立提交到商店。 因此,似乎您使用vs2012和sdk 8.0打开了项目,然后在wp8上构建并运行它,然后再次尝试为wp7设备执行此操作。 那是什么,我认为应该是问题。