簡體   English   中英

麻煩xamarin.ios / monotouch,mvvmcross和鏈接

[英]Trouble with xamarin.ios/monotouch , mvvmcross and linking

我有一個惱人的問題,如果我只在xamarin工作室使用鏈接SDK程序集我得到一個例外,如果我使用不鏈接異常沒有發生。 我已經將問題定位為我正在使用的第三方dll的一部分(api用於視頻流服務)。 我相信鏈接器正在剝離這個dll使用的一些方法。 是否可以跳過某些庫的鏈接,是否可以從這個堆棧跟蹤中查看哪些庫。

    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(感謝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] 

但它似乎沒有做到這一點 - 任何指針找到被剝離的東西?

是否可以跳過某些庫的鏈接

是。 您可以使用--linkskip=ASSEMBLY選項(在項目選項中的其他mtouch參數中)將問題(並且100%確定其來源)隔離到第三方。 它也可以用作發布解決方法(但您最好找到一個更精確的解決方案,以便從鏈接器中獲得全部好處)。

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

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

不完全的。 問題不在於System.Delegate.Combine 由於它在堆棧跟蹤中命名,因此您知道它不會被鏈接器刪除。

OTOH其中一個論點(代表)很可能被刪除。 如果它是使用反射創建的(因為鏈接器使用靜態分析),那么(很可能)會發生這種情況。 您可以使用堆棧跟蹤來查看在Combine調用中應該使用的內容(類型)並從那里向后工作,例如查找它是如何創建的。

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

  • 擁有源代碼時使用[Preserve]屬性;

  • 如果沒有源代碼,請使用XML文件 (和--xml=file );

無法協助未命名的視頻API。

但要解決Mvvmcross鏈接問題:

  • 您需要確定鏈接器錯誤發生在哪個頁面/視圖控制器上。

  • 然后你只需要添加一個LinkerPleaseInclude.cs文件來欺騙鏈接器不刪除它正在剝離的任何符號

這是一個例子: https//github.com/MvvmCross/MvvmCross-Tutorials/blob/master/DailyDilbert/DailyDilbert.Touch/LinkerPleaseInclude.cs

當鏈接器正在執行其工作時,我無法找到遺漏的內容。

但是我發現在一次綁定期間,視頻api正在進行同步的restsharp調用,這使得綁定等待完成,這似乎導致了問題。 如果我更改了工作流程並啟動了異步restsharp調用,然后在完成時啟動綁定,那么這一切都可以作為一個魅力。

謝謝你的幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM