2013-05-08 45 views
5

我有刺激性的問題,如果我使用鏈接SDK組件僅在xamarin工作室我得到一個例外,如果我不要使用鏈接的異常情況並非如此。我已將該問題定位爲我正在使用的第三方dll(針對視頻流服務的api)的一部分。我相信鏈接器正在剝離本dll所使用的一些方法。 是否有可能跳過某些庫的鏈接,並且是否可以查看來自此堆棧跟蹤的哪些內容。麻煩與xamarin.ios/MonoTouch的,mvvmcross和鏈接

2013-05-08 14:40:54.688 AppsfabrikkenTouch[5662:907] mvx: Diagnostic: 18,23 Exception masked NullReferenceException: Object reference not set to an instance of an object 
     at System.Delegate.Combine (System.Delegate a, System.Delegate b) [0x00018] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Delegate.cs:473 
    at Cirrious.MvvmCross.ViewModels.MvxNotifyPropertyChanged.add_PropertyChanged (System.ComponentModel.PropertyChangedEventHandler value) [0x00000] in <filename unknown>:0 
    at Cirrious.MvvmCross.Binding.Bindings.Source.MvxBasePropertyInfoSourceBinding..ctor (System.Object source, System.String propertyName) [0x00000] in <filename unknown>:0 
    at Cirrious.MvvmCross.Binding.Bindings.Source.MvxPropertyInfoSourceBinding..ctor (System.Object source, System.String propertyName) [0x00000] in <filename unknown>:0 
    at Cirrious.MvvmCross.Binding.Bindings.Source.Construction.MvxSourceBindingFactory.CreateBinding (System.Object source, IEnumerable`1 childPropertyNames) [0x00000] in <filename unknown>:0 
    at Cirrious.MvvmCross.Binding.Bindings.Source.Construction.MvxSourceBindingFactory.CreateBinding (System.Object source, System.String combinedPropertyName) [0x00000] in <filename unknown>:0 
    at Cirrious.MvvmCross.Binding.Binders.MvxFullBinding.CreateSourceBinding (System.Object source) [0x00000] in <filename unknown>:0 
    at Cirrious.MvvmCross.Binding.Binders.MvxFullBinding..ctor (Cirrious.MvvmCross.Binding.Interfaces.MvxBindingRequest bindingRequest) [0x00000] in <filename unknown>:0 
    at Cirrious.MvvmCross.Binding.Binders.MvxFromTextBinder.BindSingle (Cirrious.MvvmCross.Binding.Interfaces.MvxBindingRequest bindingRequest) [0x00000] in <filename unknown>:0 
    at Cirrious.MvvmCross.Binding.Binders.MvxFromTextBinder+<>c__DisplayClass1.<Bind>b__0 (Cirrious.MvvmCross.Binding.Interfaces.MvxBindingDescription description) [0x00000] in <filename unknown>:0 
    at System.Linq.Enumerable+<CreateSelectIterator>c__Iterator1D`2[Cirrious.MvvmCross.Binding.Interfaces.MvxBindingDescription,Cirrious.MvvmCross.Binding.Interfaces.IMvxUpdateableBinding].MoveNext() [0x00000] in <filename unknown>:0 
    at System.Collections.Generic.List`1[Cirrious.MvvmCross.Binding.Interfaces.IMvxUpdateableBinding].AddEnumerable (IEnumerable`1 enumerable) [0x00000] in <filename unknown>:0 
    at System.Collections.Generic.List`1[Cirrious.MvvmCross.Binding.Interfaces.IMvxUpdateableBinding].AddRange (IEnumerable`1 collection) [0x00000] in <filename unknown>:0 
    at Cirrious.MvvmCross.Binding.Touch.ExtensionMethods.MvxBindingTouchExtensions.AddBindings (IMvxBindingTouchView view, IEnumerable`1 bindings) [0x00000] in <filename unknown>:0 
    at Cirrious.MvvmCross.Binding.Touch.ExtensionMethods.MvxBindingTouchExtensions.AddBindings (IMvxBindingTouchView view, System.Object source, System.Object target, System.String bindingText) [0x00000] in <filename unknown>:0 
    at Cirrious.MvvmCross.Binding.Touch.ExtensionMethods.MvxBindingTouchExtensions.AddBindings (IMvxBindingTouchView view, System.Object source, IDictionary`2 bindingMap) [0x00000] in <filename unknown>:0 
    at Cirrious.MvvmCross.Binding.Touch.ExtensionMethods.MvxBindingTouchExtensions.AddBindings (IMvxBindingTouchView view, IDictionary`2 bindingMap) [0x00000] in <filename unknown>:0 
    at CmsApp.Touch.TabTextView.ViewDidLoad() [0x00074] in /Volumes/2end HDD/Dropbox/AppProjects/Appsfabrikken/CmsApp.Touch/Views/UmbracoViews/TabTextView.cs:45 
    at MonoTouch.UIKit.UINavigationController.PushViewController (MonoTouch.UIKit.UIViewController viewController, Boolean animated) [0x00019] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UINavigationController.g.cs:178 
    at CmsApp.Touch.AppPhonePresenter.Show (IMvxTouchView view) [0x0007b] in /Volumes/2end HDD/Dropbox/AppProjects/Appsfabrikken/CmsApp.Touch/AppPhonePresenter.cs:62 
    at Cirrious.MvvmCross.Touch.Views.Presenters.MvxTouchViewPresenter.Show (Cirrious.MvvmCross.Views.MvxShowViewModelRequest request) [0x00000] in <filename unknown>:0 
    at CmsApp.Touch.AppPhonePresenter.Show (Cirrious.MvvmCross.Views.MvxShowViewModelRequest request) [0x00000] in /Volumes/2end HDD/Dropbox/AppProjects/Appsfabrikken/CmsApp.Touch/AppPhonePresenter.cs:37 
    at Cirrious.MvvmCross.Touch.Views.MvxTouchViewDispatcher+<>c__DisplayClass1.<RequestNavigate>b__0() [0x00000] in <filename unknown>:0 
    at Cirrious.MvvmCross.Touch.Views.MvxTouchUIThreadDispatcher+<>c__DisplayClass1.<InvokeOrBeginInvoke>b__0() [0x00000] in <filename unknown>:0 

任何幫助表示讚賞。

更新: 正如stuart(謝謝斯圖爾特)所建議的,我添加了一個LinkerPleaseInclude文件,內容如下:但它仍然會出現異常。

class LinkerIncludePlease 
    { 
     private void DelegateCombine(Delegate a, Delegate b) 
     { 
      var d = Delegate.Combine(a,b); 
     } 

     private void DelegateCombine(params Delegate[] delegates) 
     { 
      var d = Delegate.Combine(delegates); 
     } 

     private void DelegateCombine() 
     { 
      var d = Delegate.Combine(); 
     } 

    } 

我的想法是,它必須是一些相關的堆棧跟蹤

Exception masked NullReferenceException: Object reference not set to an instance of an object 
      at System.Delegate.Combine (System.Delegate a, System.Delegate b) [0x00018] 

但似乎沒有這樣的伎倆 - 任何指針,以查找被剝離出來?

+0

更新後>我認爲你在linkerpleaseinclude中添加了錯誤的對象/屬性 - 你需要引用get/set無論你正在訂閱的屬性是什麼 - 例如.Text,.Video,.Whatever – Stuart 2013-05-11 10:33:11

+0

你總是斯圖爾特是完全正確的,但這不是我的問題在這裏不幸的是:( – Bjarke 2013-05-19 04:48:16

回答

1

當鏈接器完成工作時,我無法找到缺失的東西。

但是我發現在一次綁定過程中,視頻api正在進行同步restsharp調用,這會導致綁定等待完成,這似乎會導致問題。如果我改變了工作流程並開始了異步restsharp調用,然後在完成時啓動綁定,這一切都起到了魅力的作用。

非常感謝您的幫助。

5

是否有可能跳過一些圖書館

是的鏈接。您可以通過使用--linkskip=ASSEMBLY選項(在附加型mTouch參數在項目的選擇)隔離問題(並100%地肯定它的起源)到您的第三方。它也可以用作版本解決方法(但您最好找到更精確的解決方案以從鏈接器中獲得全部好處)。

例如--linkskip=mscorlib會跳過mscorlib.dll(即沒有文件擴展名)

是否有可能看到這個堆棧跟蹤?

不太。該問題與System.Delegate.Combine不符。由於它是在堆棧跟蹤中命名的,因此您知道它並未被鏈接器刪除。

它OTOH一個論點(委託)很可能刪除。如果它是使用反射創建的(因爲鏈接器使用靜態分析),可以(很可能)發生。您可以使用堆棧跟蹤來查看調用Combine時應該使用哪種類型(類型),並從那裏開始工作,例如,找出它是如何創建的。

一旦你找到它,你會希望鏈接器保持它。您可以通過添加額外的不需要的代碼(如@Stuart建議)來實現。我自己的建議是:

  • 使用時,你的源代碼[Preserve]屬性;

  • 當你沒有源代碼時,使用XML file(和--xml=file