2015-12-24 56 views
1

我的xamarin應用程序在模擬器上運行,並且在我用PC連接時也在我的設備上運行。但是,當我創建它的apk,然後安裝它在飛濺之後崩潰。我跟蹤日誌並嘗試識別但失敗。請幫我整理一下。日誌低於提及:System.Reflection.TargetInvocationException:異常已被調用的目標拋出

10時44分37秒è單:未處理的異常:

10時44分37秒è單:System.Reflection.TargetInvocationException: 異常被拋出的目標一個調用。 ---> System.TypeLoadException:無法加載類型 System.Collections.Generic.KeyValuePair`2 [[System.String, System.Runtime,Version = 4.0.0.0,Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a], [System.String,System.Runtime, 版本= 4.0.0.0,文化=中性公鑰= b03f5f7f11d50a3a]] [], mscorlib程序,版本= 2.0.5.0,文化=中性 公鑰= 7cec85d7bea7798e而解碼的自定義屬性

10點44分37秒è單:在(包裝託管到本機) System.MonoCustomAttrs:GetCustomAttributesInternal (System.Reflection.ICustomAttributeProvider,System.Type的,布爾)

10時44分37秒Ê單:在System.MonoCustomAttrs.GetCustomAttributesBase (ICustomAttributeProvider OBJ,System.Type的屬性類型,布爾 inheritedOnly)[0x00019]在:0

10時44分37秒Ë單:在System.MonoCustomAttrs.GetCustomAttributes (ICustomAttributeProvider OBJ,System.Type的屬性類型,布爾 繼承)[0x00040]在:0

10時44分37秒Ê單:在System.Reflection.MonoMethod.GetCustomAttributes (系統。類型attributeType,布爾繼承)[0x00000] in:0

10時44分37秒è單:在 System.ServiceModel.Description.ContractDescriptionGenerator.GetOrCreateOperation (System.ServiceModel.Description.ContractDescription CD, System.Reflection.MethodInfo英里,System.Reflection.MethodInfo serviceMethod,系統.ServiceModel.OperationContractAttribute酢漿草, System.Reflection.MethodInfo endMethod,布爾isCallback, 的System.Type givenServiceType)[0x0022d]在:0

10點44分37秒Ê單:在 System.ServiceModel.Description.ContractDescriptionGenerator .FillOperationsForInterface (System.ServiceModel.Description.ContractDes cription CD,System.Type的 exactContractType,System.Type的givenServiceType,布爾isCallback) [0x00134]在:0

十點44分37秒Ê單:在 System.ServiceModel.Description.ContractDescriptionGenerator.GetContractInternal (系統.TYPE givenContractType,System.Type的givenServiceType, 的System.Type serviceTypeForCallback)[0x002d4]在:0

10時44分37秒Ê單:在 System.ServiceModel.Description.ContractDescriptionGenerator.GetContract (System.Type的givenContractType ,System.Type givenServiceType, 系統。型serviceTypeForCallback)[0x00000]在:0

10時44分37秒Ê單:在 System.ServiceModel.Description.ContractDescriptionGenerator.GetContract (System.Type的givenContractType,System.Type的givenServiceType) [0x00000]中: 0

10時44分37秒Ê單:在 System.ServiceModel.Description.ContractDescriptionGenerator.GetContract (System.Type的合約類型)[0x00000]在:0

10時44分37秒Ê單:在 System.ServiceModel.Description.ContractDescription.GetContract (System.Type的合約類型)[0x00017]在:0

10時44分37秒Ê單:在 System.ServiceModel.ChannelFactory`1 [TChannel] .CreateDescription() [0x00000]在:0

10點44分37秒Ê單:在 System.ServiceModel.ChannelFactory`1 [TChannel] ..構造函數(的System.Type 型)[0x00033]在:0

10點44分37秒Ë單: at System.ServiceModel.ChannelFactory`1 [TChannel] .. ctor (System.ServiceModel.Channels.Binding binding, Sys tem.ServiceModel.EndpointAddress remoteAddress)[0x00000]在 :0

10時44分37秒Ê單:在 System.ServiceModel.ClientBase`1 [TChannel] .Initialize (System.ServiceModel.InstanceContext例如, System.ServiceModel.Channels.Binding結合, System.ServiceModel.EndpointAddress remoteAddress)[0x00000]在 :0

10時44分37秒Ê單:在System.ServiceModel.ClientBase`1 [TChannel] ..構造函數 (System.ServiceModel.InstanceContext實例, System.ServiceModel.Channels.Binding綁定, 系統.ServiceModel.EndpointAddress remoteAddress)[0x0003f]在 :0

10點44分37秒Ê單:在System.ServiceModel.ClientBase`1 [TChannel] ..構造函數 (System.ServiceModel.Channels.Binding結合, System.ServiceModel.EndpointAddress remoteAddress)[0x00000]在 :0

10時44分37秒Ê單:在AceVqbzServiceClient..ctor (System.ServiceModel.Channels.Binding結合, System.ServiceModel.EndpointAddress remoteAddress )[0x00000] :0

10: 44:37Ë單:在(包裝管理到本機) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,對象,對象[],System.Exception的&)

10時44: 37 E mono:在System.Refle

+0

您需要添加參考system.runtime版本4.0.0.0它不能加載它 – loneshark99

+0

在我的視覺工作室,它顯示它已被添加。即使當我刪除這些引用我的項目仍然在模擬器中運行,並沒有給出任何錯誤 –

+0

你需要啓用融合日誌,它會給你更多的信息,哪些程序集沒有得到加載。還檢查bin文件夾什麼是所有程序集 – loneshark99

回答

0

您是否在鏈接程序集? Xamarin包含鏈接程序集以減小APK大小的功能,但並非所有程序集似乎都允許。

要確認,我會將調試設置更改爲與發行版相同或禁用發行版的鏈接。(Build> Droid Project Options)

+0

是的,我知道了。我試圖設置鏈接沒有但仍然得到相同的錯誤。 –

+0

@AjaySharma我建議你將你的問題重命名爲「System.TypeLoadException:無法加載類型System.Collections.Generic.KeyValuePair」,因爲這是你的異常,也試圖在這些情況下使用堆棧跟蹤支付 – Niklas

+0

@Virgil什麼「堆棧跟蹤」可以做些什麼? –

1

應用程序崩潰是因爲在鏈接程序集時刪除了一些代碼。因此,您需要確定該代碼或刪除,如果您可以通過其他方式選擇其他方式,則可以根據您的錯誤日誌自定義您的鏈接器

要運行我的apk,我跳過/排除三個DLL的鏈接時創建apk。即System.Collection,System.Runtime,System.Runtime.Serialization。做你的Droid相同的項目只需右擊選擇屬性,選擇Android的選項選項卡,你在下面的圖像所見: enter image description here

相關問題