2016-07-26 91 views
0

我剛開始閱讀Charles Petzold的書用Xamarain.Forms創建移動應用程序,但沒有得到很大的進展,因爲我遇到了一些錯誤和警告,我不知道如何解決它們。我試圖卸載Visual Studios並重新安裝它無濟於事。我收到了一些錯誤和警告。剛剛安裝的Xamarin

我不確定這個問題是真的,因爲我能夠構建應用程序並將其部署到我的Android設備,以用於Portable或Shared Xamarin.Forms應用程序。我只想了解這些錯誤究竟是什麼以及如何修復它們。如果有某處我可以瞭解它們的資源,或者如果答案很簡單明瞭,我很想知道。

謝謝了,

我包括所有的錯誤,我得到了每種類型的應用程序下面的警告。

從一個空白的Xamarin.Forms便攜式應用程序開始。

第一次對話錯誤:

Package Installation Error 
Could not add all required packages to the project. 
The following packages failed to install from 
'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Microsoft.NETCore.UniversalWindowsPlatfrom.5.0.0 
: Package restore failed.Rolling back pagage changes for 'App3.UWP'. 

,並在錯誤名單上有12個警告

Severity Code Description Project File Line Suppression State 
Warning IDE0006 Error encountered while loading the project.Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled.App3  1 Active 
Warning  The "XamlCTask" task failed unexpectedly. 
System.IO.FileNotFoundException: Could not find file 'c:\users\user\documents\visual studio 2015\Projects\App3\App3\App3\obj\Debug\App3.dll'. 
File name: 'c:\users\user\documents\visual studio 2015\Projects\App3\App3\App3\obj\Debug\App3.dll' 
    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) 
    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) 
    at Mono.Cecil.ModuleDefinition.GetFileStream(String fileName, FileMode mode, FileAccess access, FileShare share) 
    at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters) 
    at Xamarin.Forms.Build.Tasks.XamlCTask.Compile() 
    at Xamarin.Forms.Build.Tasks.XamlCTask.Execute() 
    at Microsoft.Build.Framework.ITask.Execute() 
    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() 
    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() App3 
Warning IDE0006 Error encountered while loading the project.Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled.App3.Droid  1 Active 
Warning  Unexpected error - Please file a bug report at http://bugzilla.xamarin.com. Reason: System.IO.FileNotFoundException: Could not load assembly 'App3, Version=, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile? App3.Droid   
Warning Type universe cannot resolve assembly: System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.App3.UWP 
Warning  Cannot resolve Assembly or Windows Metadata file 'System.Runtime.dll' App3.UWP c:\users\user\documents\visual studio 2015\Projects\App3\App3\App3.UWP\App3.UWP.csproj 
Warning IDE0006 Error encountered while loading the project.Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled.App3.WinPhone  1 Active 
Warning  The "XamlCTask" task failed unexpectedly. 
System.IO.FileNotFoundException: Could not find file 'c:\users\user\documents\visual studio 2015\Projects\App3\App3\App3.WinPhone\obj\Debug\App3.WinPhone.exe'. 
File name: 'c:\users\user\documents\visual studio 2015\Projects\App3\App3\App3.WinPhone\obj\Debug\App3.WinPhone.exe' 
    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) 
    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) 
    at Mono.Cecil.ModuleDefinition.GetFileStream(String fileName, FileMode mode, FileAccess access, FileShare share) 
    at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters) 
    at Xamarin.Forms.Build.Tasks.XamlCTask.Compile() 
    at Xamarin.Forms.Build.Tasks.XamlCTask.Execute() 
    at Microsoft.Build.Framework.ITask.Execute() 
    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() 
    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() App3.WinPhone 
Warning IDE0006 Error encountered while loading the project.Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled.App3.Windows  1 Active 
Warning  The "XamlCTask" task failed unexpectedly. 
System.IO.FileNotFoundException: Could not find file 'c:\users\user\documents\visual studio 2015\Projects\App3\App3\App3.Windows\obj\Debug\App3.Windows.exe'. 
File name: 'c:\users\user\documents\visual studio 2015\Projects\App3\App3\App3.Windows\obj\Debug\App3.Windows.exe' 
    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) 
    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) 
    at Mono.Cecil.ModuleDefinition.GetFileStream(String fileName, FileMode mode, FileAccess access, FileShare share) 
    at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters) 
    at Xamarin.Forms.Build.Tasks.XamlCTask.Compile() 
    at Xamarin.Forms.Build.Tasks.XamlCTask.Execute() 
    at Microsoft.Build.Framework.ITask.Execute() 
    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() 
    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() App3.Windows 
Warning IDE0006 Error encountered while loading the project.Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled.App3.iOS  1 Active 
Warning  The "XamlCTask" task failed unexpectedly. 
System.IO.FileNotFoundException: Could not find file 'c:\users\user\documents\visual studio 2015\Projects\App3\App3\App3.iOS\obj\iPhone\Debug\App3iOS.exe'. 
File name: 'c:\users\user\documents\visual studio 2015\Projects\App3\App3\App3.iOS\obj\iPhone\Debug\App3iOS.exe' 
    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) 
    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) 
    at Mono.Cecil.ModuleDefinition.GetFileStream(String fileName, FileMode mode, FileAccess access, FileShare share) 
    at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters) 
    at Xamarin.Forms.Build.Tasks.XamlCTask.Compile() 
    at Xamarin.Forms.Build.Tasks.XamlCTask.Execute() 
    at Microsoft.Build.Framework.ITask.Execute() 
    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() 
    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() App3.iOS 

,並試圖構建解決方案,我得到14個錯誤和8個警告

Severity Code Description Project File Line Suppression State 
Warning The "XamlCTask" task failed unexpectedly. 
System.IO.FileNotFoundException: Could not find file 'c:\users\user\documents\visual studio 2015\Projects\App3\App3\App3.iOS\obj\iPhone\Debug\App3iOS.exe'. 
File name: 'c:\users\user\documents\visual studio 2015\Projects\App3\App3\App3.iOS\obj\iPhone\Debug\App3iOS.exe' 
    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) 
    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) 
    at Mono.Cecil.ModuleDefinition.GetFileStream(String fileName, FileMode mode, FileAccess access, FileShare share) 
    at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters) 
    at Xamarin.Forms.Build.Tasks.XamlCTask.Compile() 
    at Xamarin.Forms.Build.Tasks.XamlCTask.Execute() 
    at Microsoft.Build.Framework.ITask.Execute() 
    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() 
    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() App3.iOS 
Error  Xamarin.Forms 2.0.0.6482 is not compatible with UAP, Version = v10.0 (win10-arm-aot).   0 
Error Xamarin.Forms 2.0.0.6482 is not compatible with UAP, Version= v10.0 (win10-x64).   0 
Error Xamarin.Forms 2.0.0.6482 is not compatible with UAP, Version= v10.0.   0 
Error Some packages are not compatible with UAP, Version= v10.0 (win10-x86-aot).   0 
Error Xamarin.Forms 2.0.0.6482 is not compatible with UAP, Version= v10.0 (win10-x86-aot).   0 
Error Xamarin.Forms 2.0.0.6482 is not compatible with UAP, Version= v10.0 (win10-x86).   0 
Error Some packages are not compatible with UAP, Version = v10.0 (win10-x64-aot).   0 
Error Some packages are not compatible with UAP, Version = v10.0 (win10-arm-aot).   0 
Error Some packages are not compatible with UAP, Version = v10.0 (win10-x64).   0 
Error Some packages are not compatible with UAP, Version = v10.0 (win10-arm).   0 
Error Some packages are not compatible with UAP, Version = v10.0 (win10-x86).   0 
Error Xamarin.Forms 2.0.0.6482 is not compatible with UAP, Version= v10.0 (win10-arm).   0 
Error Some packages are not compatible with UAP, Version = v10.0.   0 
Error Xamarin.Forms 2.0.0.6482 is not compatible with UAP, Version= v10.0 (win10-x64-aot).   0 
Warning IDE0006 Error encountered while loading the project.Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled.App3  1 Active 
Warning IDE0006 Error encountered while loading the project.Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled.App3.Droid  1 Active 
Warning  Type universe cannot resolve assembly: System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.App3.UWP 
Warning  Cannot resolve Assembly or Windows Metadata file 'System.Runtime.dll' App3.UWP c:\users\user\documents\visual studio 2015\Projects\App3\App3\App3.UWP\App3.UWP.csproj 
Warning IDE0006 Error encountered while loading the project.Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled.App3.WinPhone  1 Active 
Warning IDE0006 Error encountered while loading the project.Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled.App3.Windows  1 Active 
Warning IDE0006 Error encountered while loading the project.Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled.App3.iOS  1 Active 

我能夠將Xamarin.Froms Portable調試/部署到我的Android設備。

另外,當我創建一個空白的Xamarin.forms共享應用程序時,出現對​​話框錯誤: 創建子項目「App4.UWP」時遇到問題。該項目需要一個未安裝的平臺SDK(UAP,版本= 10.0.10240.0),請訪問以下鏈接獲取更多信息:http://go.microsft.com/fwlink/?prd=12514&pver=14.0&sbp=PlatformSDKMissing&plcid=0x409&o1=UAP,%20Version=10.0.10240.0

在瀏覽器中輸入此URL我被告知無法找到DNS地址。

當完成創建項目,我有6個警告:

Severity Code Description Project File Line Suppression State 
Warning The referenced component 'System.ObjectModel' could not be found. App4.Droid 
Warning  The "XamlCTask" task failed unexpectedly. 
System.IO.FileNotFoundException: Could not find file 'c:\users\user\documents\visual studio 2015\Projects\App4\App4\App4.Droid\obj\Debug\App4.Droid.dll'. 
File name: 'c:\users\user\documents\visual studio 2015\Projects\App4\App4\App4.Droid\obj\Debug\App4.Droid.dll' 
    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) 
    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) 
    at Mono.Cecil.ModuleDefinition.GetFileStream(String fileName, FileMode mode, FileAccess access, FileShare share) 
    at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters) 
    at Xamarin.Forms.Build.Tasks.XamlCTask.Compile() 
    at Xamarin.Forms.Build.Tasks.XamlCTask.Execute() 
    at Microsoft.Build.Framework.ITask.Execute() 
    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() 
    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() App4.Droid 
Warning The "XamlCTask" task failed unexpectedly. 
System.IO.FileNotFoundException: Could not find file 'c:\users\user\documents\visual studio 2015\Projects\App4\App4\App4.WinPhone\obj\Debug\App4.WinPhone.exe'. 
File name: 'c:\users\user\documents\visual studio 2015\Projects\App4\App4\App4.WinPhone\obj\Debug\App4.WinPhone.exe' 
    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) 
    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) 
    at Mono.Cecil.ModuleDefinition.GetFileStream(String fileName, FileMode mode, FileAccess access, FileShare share) 
    at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters) 
    at Xamarin.Forms.Build.Tasks.XamlCTask.Compile() 
    at Xamarin.Forms.Build.Tasks.XamlCTask.Execute() 
    at Microsoft.Build.Framework.ITask.Execute() 
    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() 
    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() App4.WinPhone 
Warning IDE0006 Error encountered while loading the project.Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled.App4.Windows  1 Active 
Warning The "XamlCTask" task failed unexpectedly. 
System.IO.FileNotFoundException: Could not find file 'c:\users\user\documents\visual studio 2015\Projects\App4\App4\App4.Windows\obj\Debug\App4.Windows.exe'. 
File name: 'c:\users\user\documents\visual studio 2015\Projects\App4\App4\App4.Windows\obj\Debug\App4.Windows.exe' 
    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) 
    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) 
    at Mono.Cecil.ModuleDefinition.GetFileStream(String fileName, FileMode mode, FileAccess access, FileShare share) 
    at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters) 
    at Xamarin.Forms.Build.Tasks.XamlCTask.Compile() 
    at Xamarin.Forms.Build.Tasks.XamlCTask.Execute() 
    at Microsoft.Build.Framework.ITask.Execute() 
    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() 
    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() App4.Windows 

當我構建解決方案,我得到3個警告

Severity Code Description Project File Line Suppression State 
Warning The "XamlCTask" task failed unexpectedly. 
System.IO.FileNotFoundException: Could not find file 'c:\users\user\documents\visual studio 2015\Projects\App4\App4\App4.iOS\obj\iPhone\Debug\App4iOS.exe'. 
File name: 'c:\users\user\documents\visual studio 2015\Projects\App4\App4\App4.iOS\obj\iPhone\Debug\App4iOS.exe' 
    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 
    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) 
    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) 
    at Mono.Cecil.ModuleDefinition.GetFileStream(String fileName, FileMode mode, FileAccess access, FileShare share) 
    at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters) 
    at Xamarin.Forms.Build.Tasks.XamlCTask.Compile() 
    at Xamarin.Forms.Build.Tasks.XamlCTask.Execute() 
    at Microsoft.Build.Framework.ITask.Execute() 
    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() 
    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() App4.iOS 
Warning  The referenced component 'System.ObjectModel' could not be found.App4.Droid 
Warning IDE0006 Error encountered while loading the project.Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled.App4.Windows  1 Active 

我能夠構建和調試/部署Xamarin .Forms共享到我的Android設備。

那麼我需要做些什麼來解決這些警告和錯誤?

+0

嘿!我已經能夠重現這個問題。我將進一步研究,並會讓你知道一個解決方法ASAP – clb

+0

嘿。所以這就是我的位置。我可以通過以下步驟重現這些錯誤。新建共享項目>構建>更新nuget>構建,並且每次我通過執行以下操作(在收到此錯誤後)解決此問題時關閉Visual Studio>打開Visual Studio>清理項目>構建。你能否嘗試這些步驟,讓我知道它是否解決了這個問題? – clb

回答

0

對於這些問題,我有一些解決方法和一些前進的方法。首先,應該指出,這些似乎是不同的問題,但我會盡我所能回答。

首先,對於更新NuGet包後可能出現的錯誤,通常可以通過清理項目來解決。因此,步驟是:更新包>關閉Visual Studio的>打開Visual Studio>清理項目>構建

對於XAMLC錯誤後,我建立了Xamarin's bug tracking tool

對於IDE0006錯誤的錯誤,我也創建a new bug

對於以下錯誤:

'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Microsoft.NETCore.UniversalWindowsPlatfrom.5.0.0 
: Package restore failed.Rolling back pagage changes for 'App3.UWP'. 

我一直無法重現的錯誤。但我會努力。只要我可以,我會更新這篇文章。

謝謝!

0

通過更新的NuGet等,我已經擺脫了所有的錯誤,除了編制「歡迎使用Xamarin窗體」模板時,下列 - 嚴重性代碼說明項目文件的線路抑制狀態 警告引用的組件「System.ObjectModel '找不到。

+0

歡迎來到Stack Overflow!這並不能解答這個問題。要批評或要求作者澄清,在他們的帖子下留下評論 - 你總是可以評論你自己的帖子,一旦你有足夠的[聲譽](http://stackoverflow.com/help/whats-reputation),你會能夠[評論任何帖子](http://stackoverflow.com/help/privileges/comment)。 –

相關問題