2013-03-21 58 views
1

我一直在使用MvvmCross v1一段时间了,&我觉得它非常有用&不是太难用!所以我点点滴滴&决定使用vnext进行下一个项目。一切都很好,直到我试图用一个插件,它具有以下输出崩溃 -MvvmCross vnext - 插件问题

2013-03-21 18:14:27.121 MyApp[85942:11903] mvx: Diagnostic: 0,00 Setup: Text serialization start 
2013-03-21 18:14:27.124 MyApp[85942:11903] mvx: Diagnostic: 0,03 Setup: PlatformServices start 
2013-03-21 18:14:27.125 MyApp[85942:11903] mvx: Diagnostic: 0,03 Setup: ViewModelFramework start 
2013-03-21 18:14:27.126 MyApp[85942:11903] mvx: Diagnostic: 0,03 Setup: PluginManagerFramework start 
2013-03-21 18:14:27.127 MyApp[85942:11903] mvx: Diagnostic: 0,03 Setup: App start 

Unhandled Exception: 
0 MyApp      0x00079b12 mono_handle_exception_internal_first_pass + 3058 
1 MyApp      0x0007b1e2 mono_handle_exception_internal + 1602 
2 MyApp      0x0007bd2f mono_handle_exception + 47 
3 MyApp      0x000bce22 mono_x86_throw_exception + 306 
4 ???         0x07986f8f 0x0 + 127430543 
at Cirrious.MvvmCross.Plugins.MvxBasePluginManager.ExceptionWrappedLoadPlugin (System.Type) <IL 0x00002, 0x0001f> 
at Cirrious.MvvmCross.Plugins.MvxBasePluginManager.EnsureLoaded<T>() <IL 0x00030, 0x0008c> 
at Cirrious.MvvmCross.Plugins.Share.PluginLoader.EnsureLoaded() <IL 0x00008, 0x00029> 
at MyApp.Core.BaseApp.InitialisePlugins() [0x00000] in /Users/franklyn/Documents/Programming/MyApp/MyApp.Core/App.cs:42 

它发生每当我试图LO加载具有“触摸”项目元素的插件,其他如JsonLocalisation插件没有,加载好。

如果有其他人遇到此问题,请告诉我们,我很乐意听到他们的消息。

+0

您是否尝试在调试模式下进入并缩小它到底在哪里破坏? – Cheesebaron 2013-03-21 19:44:07

回答

2

对于Android,插件加载只是因为他们在那里 - 他们的文件,并可以通过Assembly.Load

对于iOS加载,插件无法加载,因为名列前茅的时间编制要求这样。

为了解决这个问题,iOS中的所有特定于平台的插件都必须在安装过程中进行注册。

可以将所有样品中看到SetupAddPluginLoaders这段代码 - 看https://github.com/slodge/MvvmCross/blob/vnext/Sample%20-%20TwitterSearch/TwitterSearch.UI.Touch/Setup.cs

protected override void AddPluginsLoaders(MvxLoaderPluginRegistry registry) 
{ 
    registry.AddConventionalPlugin<Cirrious.MvvmCross.Plugins.Visibility.Touch.Plugin>(); 
    registry.AddConventionalPlugin<Cirrious.MvvmCross.Plugins.File.Touch.Plugin>(); 
    registry.AddConventionalPlugin<Cirrious.MvvmCross.Plugins.DownloadCache.Touch.Plugin>(); 
    base.AddPluginsLoaders(registry); 
} 

总体而言,插件机制比老v1代码要好得多,因为它意味着更少的有害代码是包含在你的应用程序中,因为它是可扩展的。


有关为什么Assembly.Load无法在iOS中使用最近的讨论,请参见http://forums.xamarin.com/discussion/comment/7882 - 我试图避免这一步。

+0

谢谢Stuart - 我现在正在运行。我知道AOT的要求,我只是没有弄清楚你是如何初始化插件的。我现在还有一个问题需要重新初始化GeoLocationWatcher - 我会把它作为另一个问题。 – SomaMan 2013-03-22 09:26:54