Maintenance error for type 'Microsoft.Framework.Runtime.IApplicationEnvironment
So now we're trying to test the new Visual Studio Code on OS X, but we're running into a lot of problems.
Currently the problem with the dnu command has been fixed, but now there are problems with:
dnx . kestrel
This belongs to the Commands with Ease section from Visual Studio Code and has the following error: message shown in my terminal. So far everything is step by step and still had problems.
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.
source to share
If you are using a runtime version that still uses IApplicationEnvironment
instead IHostingEnvironment
, then the problem is that DNVM cannot find the default runtime.
This could be because the runtime is not installed or Visual Studio is not configured correctly in the global.json file .
Decision:
- to make sure the target runtime version is set, type in a terminal:
dnvm list
-
if runtime is not listed (not listed) set it with
dnvm install <runtime> -a <architecture> -r <runtime>
(ex: willdnvm install 1.0.0-rc1-update2 -a x64
install the x64 version of the specified runtime
ordnvm install 1.0.0-rc1-update2 -r clr
will install the CLR version to run)
You can also set the specified runtime as default , active and make your settings permanent . -
at this point you can run your application from cmd
- to be able to run it from Visual Studio, you must specify the correct execution version in the global.json file , which must be located 2 nodes above the project folder: (../GlobalJsonPlace/src/ProjectFolder/ ..)
If you don't have a file global.json , 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 containing the project folder.
- restart your VS instance and it should be able to run your application.
source to share