2016-09-27 92 views
2

我正在使用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. 

回答

0

您可以嘗試清潔UWP項目和重新構建。

+0

我正在使用空白XAML應用程序(Xamarin.Forms便攜式)解決方案使用C#跨平臺沒有添加代碼。 UWP項目在Xamarin.Forms.Forms.Init(e) –

+0

失敗您運行什麼目標? Windows 10桌面 Windows 10模擬器 Windows 10移動模擬器 Windows 10移動電話 –

+0

Windows 10桌面 –

1

在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解決方法。

+1

更新到塞拉利昂並沒有改變一件事。 –