I just started reading Charles Petzold's book Creating Mobile Apps with Xamarain.Forms but didn't get very far at all because I've hit a number of errors and warnings and am not sure how to fix them. I have tried uninstalling Visual Studios and reinstalling it to no avail.
I am uncertain what the issue is really because I am able to build and deploy the app to my Android device for either the Portable or Shared Xamarin.Forms app.I would just like to understand what these errors are exactly and how to fix them. If there is a resource somewhere that I can learn about them or if the answer is simple and straightforward I'd love to know.
Thanks much,
I included all the errors and warnings I got for each type of app below.
Starting with a blank Xamarin.Forms Portable app.
First dialogue error:
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'.
And in the Error List I have 12 Warnings
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
And when trying to build the solution I get 14 Errors and 8 Warnings
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
I am able to debug/deploy the Xamarin.Froms Portable to my Android Device.
Also when I create a blank Xamarin.forms Shared app I get the dialog error:
A problem was encountered creating the sub project 'App4.UWP'. The project requires a platform SDK (UAP, Version=10.0.10240.0) that is not installed please visit the folllowing link for more information: http://go.microsft.com/fwlink/?prd=12514&pver=14.0&sbp=PlatformSDKMissing&plcid=0x409&o1=UAP,%20Version=10.0.10240.0
Entering this url into my browser I am told the DNS address could not be found.
When it is finished creating the project I have 6 Warnings:
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
When I build the solution I get 3 Warnings
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
I am able to build and debug/deploy the Xamarin.Forms Shared to my Android device.
So what do I need to do to resolve these warnings and errors?
I have some answers, and some ways forward, for these issues. First, it should be noted that these appear to be disparate issues, but I will answer each as I can.
First, for the errors that may occur after updating NuGet Packages, those can generally be solved by cleaning the project. So steps would be: After updating packages > close Visual Studio > Open Visual Studio > Clean Project > Build
For the XAMLC error, I have created a bug on Xamarin's bug tracking tool
For the IDE0006 error, I have also created a new bug
For the the following error:
'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Microsoft.NETCore.UniversalWindowsPlatfrom.5.0.0
: Package restore failed.Rolling back pagage changes for 'App3.UWP'.
I've been unable to reproduce that error. But I will kep trying. As soon as I can, I will update this post.
Thanks!
By updating nuget, etc., I have gotten rid of all errors except the following when compiling the "Welcome to Xamarin Forms" template -
Severity Code Description Project File Line Suppression State
Warning The referenced component 'System.ObjectModel' could not be found.
So right now trying to test out the new Visual Studio Code on OS X, but running into a myriad of issues.
Right now been sort out the issue with the dnu command, but now having issues with:
dnx . kestrel
This would be in relation to the Commands with Ease section from the Visual Studio Code and having the following error message shown in my terminal. So far followed everything step by step and still having issues.
System.InvalidOperationException: No service for type 'Microsoft.Framework.Runtime.IApplicationEnvironment' has been registered.
at Microsoft.Framework.DependencyInjection.ServiceProviderExtensions.GetRequiredService (IServiceProvider provider, System.Type serviceType) [0x00000] in <filename unknown>:0
at Microsoft.Framework.DependencyInjection.ServiceProviderExtensions.GetRequiredService[IApplicationEnvironment] (IServiceProvider provider) [0x00000] in <filename unknown>:0
at Microsoft.AspNet.Hosting.HostingEngine..ctor (IServiceProvider fallbackServices) [0x00000] in <filename unknown>:0
at Microsoft.AspNet.Hosting.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute (System.Reflection.Assembly assembly, System.String[] args, IServiceProvider serviceProvider) [0x00000] in <filename unknown>:0
at Microsoft.Framework.ApplicationHost.Program.ExecuteMain (Microsoft.Framework.Runtime.DefaultHost host, System.String applicationName, System.String[] args) [0x00000] in <filename unknown>:0
at Microsoft.Framework.ApplicationHost.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute (System.Reflection.Assembly assembly, System.String[] args, IServiceProvider serviceProvider) [0x00000] in <filename unknown>:0
at dnx.host.Bootstrapper.RunAsync (System.Collections.Generic.List`1 args) [0x00000] in <filename unknown>:0
Hope you guys can help.
I had a similar issue when trying to run from the \samples\latest folder instead of \samples\1.0.0-beta4 folder. Simply trying again from where I was supposed to be worked.
If you are using a runtime version which is still using IApplicationEnvironment instead of only IHostingEnvironment, than the problem is DNVM can not find the default runtime.
It can be because the runtime is not installed, or Visual Studio is not configured correctly by global.json file.
Solution:
to make sure the targeted runtime version has been installed, type into terminal:
dnvm list
if the runtime has not been listed (not on the list), install it with
dnvm install <runtime> -a <architecture> -r <runtime>
(for example:
dnvm install 1.0.0-rc1-update2 -a x64 would install an x64 version of the specified runtime
or dnvm install 1.0.0-rc1-update2 -r clr would install the clr version of the runtime)
You can also set the specified runtime as default, active, and make your settings persistent.
in this phase you can probably run your application from cmd
in order to be able to run it from Visual Studio, you have to specify the correct runtime version in the global.json file, which must be located 2 nodes above the project's folder: (../GlobalJsonPlace/src/ProjectFolder/..)
If you do not have the global.json file, create it. It should be something like:
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-rc1-update2"
}
}
Note: src is the name of the folder, which contains the project's folder.
reload your VS instance, and it should be able to run your application.
I have a xamarin forms application where the very first page has a image control which displays a embedded resource. Often, when i run the application, it fails during start-up with following error:
[libc] WARNING: generic atexit() called from legacy shared library
[monodroid-gc] GREF GC Threshold: 46800
[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] Xamarin.Forms.Xaml.XamlParseException: No embeddedresources found for SeeVee.StartPage
[MonoDroid] at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject view, System.Type callingType) [0x00000] in <filename unknown>:0
[MonoDroid] at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[StartPage] (SeeVee.StartPage view, System.Type callingType) [0x00000] in <filename unknown>:0
[MonoDroid] at SeeVee.StartPage.InitializeComponent () [0x00000] in <filename unknown>:0
[MonoDroid] at SeeVee.StartPage..ctor () [0x00000] in <filename unknown>:0
[MonoDroid] at SeeVee.App.GetMainPage () [0x00000] in <filename unknown>:0
[MonoDroid] at SeeVee.Android.MainActivity+<OnCreate>d__0.MoveNext () [0x00000] in <filename unknown>:0
[mono]
[mono] Unhandled Exception:
[mono] Xamarin.Forms.Xaml.XamlParseException: No embeddedresources found for SeeVee.StartPage
[mono] at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject view, System.Type callingType) [0x00000] in <filename unknown>:0
[mono] at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[StartPage] (SeeVee.StartPage view, System.Type callingType) [0x00000] in <filename unknown>:0
[mono] at SeeVee.StartPage.InitializeComponent () [0x00000] in <filename unknown>:0
[mono] at SeeVee.StartPage..ctor () [0x00000] in <filename unknown>:0
[mono] at SeeVee.App.GetMainPage () [0x00000] in <filename unknown>:0
[mono] at SeeVee.Android.MainActivity+<OnCreate>d__0.MoveNext () [0x00000] in <filename unknown>:0
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: Xamarin.Forms.Xaml.XamlParseException: No embeddedresources found for SeeVee.StartPage
[mono-rt] at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject view, System.Type callingType) [0x00000] in <filename unknown>:0
[mono-rt] at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[StartPage] (SeeVee.StartPage view, System.Type callingType) [0x00000] in <filename unknown>:0
[mono-rt] at SeeVee.StartPage.InitializeComponent () [0x00000] in <filename unknown>:0
[mono-rt] at SeeVee.StartPage..ctor () [0x00000] in <filename unknown>:0
[mono-rt] at SeeVee.App.GetMainPage () [0x00000] in <filename unknown>:0
[mono-rt] at SeeVee.Android.MainActivity+<OnCreate>d__0.MoveNext () [0x00000] in <filename unknown>:0
I have to rebuild the app in xamarin studio and re-run and it works. Phew! this gets very tiring sometimes. I hope xamarin is aware of this silly bug and will fix it.
It's a bug. For some reason its status is RESOLVED FIXED, but it doesn't seem fixed at all. On XS on mac anyway.
As a workaround, the file that the exception is thrown in, SomeClass.g.cs, just make an edit to that one generated file, save it, and build again. A bit faster than rebuilding everything.
Of course this means every time you change a .xaml file, you have to build twice.
The fix that worked for me was the following
In the main project .csproj file, I found that all my .xaml files where formatted like this :
<EmbeddedResource Include="Source\Home\HomeContentView.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
Except one, the one that was failing had an extra line which looked like this
<LogicalName>MyProject.Home.HomeContentView.xaml</LogicalName>
Removing this line fixed the issue. I also saved my files, cleaned and rebuilt the project.
I had a similar error and fixed it by correcting the class name in my xaml file.
I mean in the x:Class attribute of my page.
I'm using Visual Studio Community 2017 for Mac. I changed my quote char from double quotes (") to single quotes (') and formatted my files. Suddenly I started to get this error whenever the formatted ContentPage was Initialised.
I went back into:
'Visual Studio Community' -> 'Preferences' -> 'Source Code' -> 'Code Formatting' -> 'XML document' -> 'XML Format' -> Quote char
changed it back to double quotes, formatted the documents that I had formatted with the single quotes back to double quotes ('Edit'->'Format'->'Format Document') and now it is working perfectly again.
This fixed my problem with:
'Xamarin.Forms.Xaml.XamlParseException has been thrown'
'No embeddedresource found for YourNamespace.YourContentPageName'
Hope it helps!
After upgrading to visual studio 2017 and latest version of Xamarin this happened to me no matter what I tried. It was the correct class name. Nothing changed in the XAML for this to make sense and to keep getting kicked out of the ios build and android build with the embedded resource not found error. The only solution is to save your xaml and code behind in a notepad then delete that class permanently from your project. Add a new ContentPage to your Xamarin.Forms portable project and name it something different. Paste your code back in and save. Update your project to look for that new ContentPage name. Then it will work for you again.
Another option is to check whether the item is in the Remove list in an ItemGroup which could have been excluded in the past:
Trying to work with the new omnisharp using vim.
My current setup is vim with omnisharp-vim.
The github pages for those direct toward initiating the omnisharp-server client manually in the project directory (so it can index all the .cs files), and then attempting to use vim.
Problem is I can't start the omnisharp-server.
After following the steps on the github page: https://github.com/OmniSharp/omnisharp-server
I get the following error (running from the vim bundle directory or just a newly cloned and xbuilt directory)
HelloMvc>$ mono ~/.vim/bundle/Omnisharp/server/OmniSharp/obj/Debug/OmniSharp.exe -s .
Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'Nancy.Hosting.Self,
Version=0.22.2.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
File name: 'Nancy.Hosting.Self, Version=0.22.2.0, Culture=neutral, PublicKeyToken=null'
at OmniSharp.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly
'Nancy.Hosting.Self, Version=0.22.2.0, Culture=neutral, PublicKeyToken=null' or one of its
dependencies.
File name: 'Nancy.Hosting.Self, Version=0.22.2.0, Culture=neutral, PublicKeyToken=null'
at OmniSharp.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
So it appears that mono doesn't have the Nancy.Hosting.Self assembly?
So I manually downloaded the Nancy project and attempted to build it and got this error:
/Users/me/seesharp/Nancy/src/Nancy.sln (default targets) ->
(Build target) ->
/Users/me/seesharp/Nancy/src/Nancy.Hosting.Wcf/Nancy.Hosting.Wcf.csproj (default targets) ->
/usr/local/Cellar/mono/3.10.0/lib/mono/4.5/Microsoft.CSharp.targets (CoreCompile target) ->
NancyWcfGenericService.cs(65,31): error CS1061: Type `System.ServiceModel.Web.WebOperationContext'
does not contain a definition for `CreateStreamResponse' and no extension method
`CreateStreamResponse' of type `System.ServiceModel.Web.WebOperationContext' could be found. Are you
missing an assembly reference?
ok that's weird since the github page says it's building, so let's see the code that's failing:
[WebInvoke(UriTemplate = "*", Method = "*")]
public Message HandleRequests(Stream requestBody)
{
var webContext = WebOperationContext.Current;
var nancyRequest =
CreateNancyRequestFromIncomingWebRequest(webContext.IncomingRequest, requestBody, OperationContext.Current);
var nancyContext =
engine.HandleRequest(nancyRequest);
SetNancyResponseToOutgoingWebResponse(webContext.OutgoingResponse, nancyContext.Response);
return webContext.CreateStreamResponse(
stream =>
{
nancyContext.Response.Contents(stream);
nancyContext.Dispose();
},
nancyContext.Response.ContentType ?? string.Empty);
}
and at the top of the file
using System.ServiceModel.Web;
The reference is also present in the projects .csproj file.
So what is going on, and if I've gone too far in the wrong direction, how can I get omnisharp-server to work while I wait for a fix in either the omnisharp-vim or youcompleteme plugins that take care of this?
edit:
Ok so after trying out the mvcmusicstore app and loading that, I see that the way vim says it's running mono is like this:
mono '/Users/me/.vim/bundle/Omnisharp/server/OmniSharp/bin/Debug/OmniSharp.exe' -p 2000 -s .
but this is giving me the following error:
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
at OmniSharp.Solution.CSharpProject.AddReference (IAssemblyReference reference) [0x00000] in <filename unknown>:0
at OmniSharp.Solution.CSharpProject.AddMsCorlib () [0x00000] in <filename unknown>:0
at OmniSharp.Solution.CSharpProject..ctor (ISolution solution, OmniSharp.Logger logger, System.String folderPath) [0x00000] in <filename unknown>:0
at OmniSharp.Solution.CSharpFolder.LoadSolution () [0x00000] in <filename unknown>:0
at OmniSharp.Program.StartServer (System.String solutionPath, System.String clientPathMode, Int32 port, Verbosity verbosity, System.String configLocation) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
at OmniSharp.Solution.CSharpProject.AddReference (IAssemblyReference reference) [0x00000] in <filename unknown>:0
at OmniSharp.Solution.CSharpProject.AddMsCorlib () [0x00000] in <filename unknown>:0
at OmniSharp.Solution.CSharpProject..ctor (ISolution solution, OmniSharp.Logger logger, System.String folderPath) [0x00000] in <filename unknown>:0
at OmniSharp.Solution.CSharpFolder.LoadSolution () [0x00000] in <filename unknown>:0
at OmniSharp.Program.StartServer (System.String solutionPath, System.String clientPathMode, Int32 port, Verbosity verbosity, System.String configLocation) [0x00000] in <filename unknown>:0
Turns out that this is an issue with omnisharp-vim.
Downloading, building, and running the omnisharp-server solution fixed this issue for me
Edit: This has been fixed in the omnisharp-vim plugin. Pull latest and rebuild and you should be fine. Thanks to the maintainer.