Xamarin UWP应用程序不起作用
我正在使用Visual Studio Update 3 + Update 3修补程序。我创建了一个空白XAML应用程序(Xamarin.Forms便携式)解决方案使用C#跨平台模板。我在配置管理器中检查了构建和部署。我已经更新了解决方案Xamarin.Forms 2.3.2.127(2.2版本有同样的问题)。到目前为止,我已经能够运行Android和iOS应用程序。我没有修改源代码,我正在使用空的项目。当试图运行UWP应用程序,我在App.xaml.cs得到一个错误:Xamarin UWP应用程序不起作用
Xamarin.Forms.Forms.Init(e)
System.AggregateException: One or more errors occurred.
(Error HRESULT E_FAIL has been returned from a call to a COM component.) --->
System.Runtime.InteropServices.COMException:
Error HRESULT E_FAIL has been returned from a call to a COM component.
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at System.Threading.Tasks.Task`1.get_Result()
at Xamarin.Forms.Platform.UWP.WindowsBasePlatformServices.GetAssemblies()
at Xamarin.Forms.Registrar.RegisterAll(Type[] attrTypes)
at Xamarin.Forms.Forms.Init(IActivatedEventArgs launchActivatedEventArgs, IEnumerable`1 rendererAssemblies)
at Tester.UWP.App.OnLaunched(LaunchActivatedEventArgs e)
---> (Inner Exception #0) System.Runtime.InteropServices.COMException (0x80004005):
Error HRESULT E_FAIL has been returned from a call to a COM component.
您可以尝试清洁UWP项目和重新构建。
在VMware Fusion V8.5.0(4352717)中,当在Windows 10 Enterprise 2015 LTSB上作为来宾操作系统运行Visual Studio 2015时,我遇到了完全相同的问题。主机操作系统是OSX El Captitan 10.11.6。
否则我有相同的设置:在运行UWP项目时,空白Xamarin项目(共享和可移植)具有完全相同的结果。来自Xamarin网站的TodoREST示例也发生了同样的情况。当使用VS进行调试时,几个 System.InvalidCastException在Xamarin.Forms.Forms.Init(e)中的断点处显示在“this”,“e”和“rootFrame”内部。即:
this.FocusVisualKind' threw an exception of type 'System.InvalidCastException
at System.StubHelpers.StubHelpers.GetCOMIPFromRCW_WinRT(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget)\r\n at Windows.UI.Xaml.Application.get_FocusVisualKind()"
Message "Unable to cast object of type 'TodoREST.UWP.App' to type 'Windows.UI.Xaml.IApplication2'."
我试过几件事情
- 更新任何可能
- 干净的东西可能
- 降级Xamarin在步骤2.0
- 重新安装从Xamarin下载网站VS2015社区(包括Xamarin 4.1)
- 重新安装VS2015 Community和Xamarin 4.2之后
但似乎没有什么影响这个例外。
最后,我去了一个物理Windows 10笔记本电脑,它的工作就像一个魅力。
所以我最好猜测的是,Windows在VMware内部作为Guest OS运行的事实与此错误有关。
由于我已经浪费了太多时间在这方面,我要尝试的唯一一件事就是将OSX更新到Sierra。要么它工作,要么我会留在“原生”Windows解决方法。
更新到塞拉利昂并没有改变一件事。 –
我正在使用空白XAML应用程序(Xamarin.Forms便携式)解决方案使用C#跨平台没有添加代码。 UWP项目在Xamarin.Forms.Forms.Init(e) –
失败您运行什么目标? Windows 10桌面 Windows 10模拟器 Windows 10移动模拟器 Windows 10移动电话 –
Windows 10桌面 –