2014-05-21 25 views
1

我有一個很大的wp7項目,它在wp7上運行良好。在過去的幾個星期裏,我使用wp8設備進行調試(項目仍然是wp7)並且很好。現在在wp7上運行項目時出現TargetInvocationException

,我開始測試其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。目前它正爲:enter image description here

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中臨,臨MSVS 2012更新4

+0

不能進行有針對性的對WP7 WP8的應用程序。您或者必須有兩個單獨的項目以WP7和WP8爲目標,或者讓該項目以WP7爲目標,所以兩個OS都可以運行該應用程序。 –

+0

這是wp7應用程序。剛剛編輯的問題,以澄清這一點。 –

+0

因此,您將其定位到WP8並將其更改回WP7? –

回答

1

好的,我設法解決了這個問題。問題在於Newtonsoft.Json庫,當前版本(6.0.3)聲稱與wp7兼容,但在實踐中它不是。

enter image description here

解決方法:只回滾到5.0.8: Install-Package Newtonsoft.Json -Version 5.0.8

+0

因此,這是您的項目的內部,沒有任何與使用wp8 wp7設備和任何項目目標更改相關的內容。那麼,偉大的:) –

+0

@GauravDeochakke是的:)但是,我得到了另一個問題:服務器調用工作正常wp8和拋出wp7 NotFound異常:http://stackoverflow.com/questions/23816912/network-errors-on -wp7 –

0

一旦你在VS 2012年WP SDK 8.0與WP8目標平臺打開你的WP7應用程序,你不能再使用這個項目作爲WP7項目。如果你想在VS 2012的新環境中繼續開發,你需要使用目標平臺:WP 7.1。 檢查目標平臺的設置。

如果您要支持WP 7 OS,您需要維護兩個不同的應用程序並將其獨立提交給商店。 因此,你似乎用vs2012和sdk 8.0打開了這個項目,然後在wp8上創建並運行它,然後再次嘗試爲wp7設備這麼做。 那是什麼,我認爲應該是問題。

+0

感謝您的答案。但項目**是** wp7導向。我更新了問題。通常,我submited一個WP7項目,它可以在兩個wp7和wp8。 –

+0

請您澄清一下:「在上次使用wp8設備進行調試時,我開發了它(項目仍然是wp7)。」您的這種說法? 這讓我想到了一個錯誤的方向。 –

+0

是的,對不起 - 看起來像我以一種相當奇怪的方式制定它。我意識到我使用wp8設備來測試wp7項目,這很好。現在我使用wp7設備來測試相同的wp7項目,但它引發了一個異常。 –

相關問題