我为Windows Phone 8.1和iOS开发了MvvmCross的自定义插件
在iOS项目中加载但在Windows Phone 8.1的 manager.EnsurePlatformAdaptionLoaded();
中出错public class PluginLoader : IMvxPluginLoader
{
public static readonly PluginLoader Instance = new PluginLoader();
public void EnsureLoaded()
{
var manager = Mvx.Resolve<IMvxPluginManager>();
manager.EnsurePlatformAdaptionLoaded<PluginLoader>();
}
}
错误
类型&#39; Cirrious.CrossCore.Exceptions.MvxException&#39;的例外情况 发生在Cirrious.CrossCore.DLL但未在用户代码中处理
其他信息:无法加载类型的插件程序集 Confiz.MvvmCross.Plugins.Timer.PluginLoader
我使用以下代码
在Windows Phone 8.1中加载我的插件 public class TimerPluginBootstrap : MvxPluginBootstrapAction<Confiz.MvvmCross.Plugins.Timer.PluginLoader>
{
}
我正在使用 Windows Phone 8.1 和 MvvmCross 3.2.1 ,以下是更多信息
Confiz.MvvmCross.Plugins.Timer(便携式)
ITimer.cs
public interface ITimer
{
void Start();
void Stop();
Action CallBackMethod { get; set; }
}
PluginLoader.cs
public class PluginLoader : IMvxPluginLoader
{
public static readonly PluginLoader Instance = new PluginLoader();
public void EnsureLoaded()
{
var manager = Mvx.Resolve<IMvxPluginManager>();
manager.EnsurePlatformAdaptionLoaded<PluginLoader>();
}
}
Confiz.MvvmCross.Plugins.Timer.WindowsPhone
MvxWindowsPhoneTimer.cs
public class MvxWindowsPhoneTimer : ITimer
{
private readonly DispatcherTimer timer;
public MvxWindowsPhoneTimer(double kronosApiRecallTimeInMinutes)
{
timer = new DispatcherTimer();
Timer.Interval = TimeSpan.FromSeconds(kronosApiRecallTimeInMinutes);
Timer.Tick += Timer_Tick;
}
void Timer_Tick(object sender, object e)
{
CallBackMethod.Invoke();
}
public DispatcherTimer Timer
{
get { return timer; }
}
public void Start()
{
Timer.Start();
}
public void Stop()
{
Timer.Stop();
}
public Action CallBackMethod { get; set; }
}
Plugin.cs
public class Plugin : IMvxPlugin
{
public void Load()
{
Mvx.RegisterSingleton<ITimer>(new MvxWindowsPhoneTimer(1));
}
}
答案 0 :(得分:1)
Silverlight的插件扩展名为WindowsPhone
对于Jupiter Xaml Windows Phone应用,扩展名为WindowsCommon
(如果与Win81共享),WindowsPhoneStore
仅限商店。
所以Confiz.MvvmCross.Plugins.Timer.WindowsPhone.dll
适用于Silverlight
Confiz.MvvmCross.Plugins.Timer.WindowsPhoneStore.dll
适用于Jupiter Xaml应用