Upgrading VS2015 to asp.net 5 beta7 I get Could not load file or assembly 'dnx.clr.managed' or one of its dependencies

一个人想着一个人 提交于 2019-12-10 15:57:28

问题


I have upgraded DNX using the instructions on https://github.com/aspnet/Home I also downloaded DotNetVersionManager-x64.msi for visual studio 2015 but when I create a new project and run the website I get the following error

Could not load file or assembly 'dnx.clr.managed' or one of its dependencies. The system cannot find the file specified. 

When I try to run the website from dnx command line I get the following

C:\code> dnx web stem.InvalidOperationException: No service for type 'Microsoft.Framework.Runtime.IApplicationEnvironment' has been reg tered. at Microsoft.Framework.DependencyInjection.ServiceProviderExtensions.GetRequiredService(IServiceProvider provider, Ty serviceType) at Microsoft.Framework.DependencyInjection.ServiceProviderExtensions.GetRequiredService[T](IServiceProvider provider)

at Microsoft.AspNet.Hosting.Program.Main(String[] args) - End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider service ovider) at Microsoft.Dnx.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String[] args) at Microsoft.Dnx.ApplicationHost.Program.Main(String[] args) - End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider service ovider) at Microsoft.Dnx.Host.Bootstrapper.RunAsync(List`1 args, IRuntimeEnvironment env, FrameworkName targetFramework) at Microsoft.Dnx.Host.RuntimeBootstrapper.ExecuteAsync(String[] args, FrameworkName targetFramework) at Microsoft.Dnx.Host.RuntimeBootstrapper.Execute(String[] args, FrameworkName targetFramework)


回答1:


Looks like beta7 doesn't carry the dnx.clr.managed.dll anymore (and its dependencies). I've solved this problem with the following steps:

You can check if your global.json file is expecting beta7 by looking for the following node in global.json:

"sdk": {
        "version": "1.0.0-beta7",
        "runtime": "clr",
        "architecture": "x86"
    }

If your project keeps looking for the dnx.clr.managed.dll (and its dependencies), you can manually edit your project.json file (which stores the dependencies and replaces the old cs.proj and vb.proj files), to point to the expected dnx runtime version, for example:

"dependencies": {
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-beta5"
  },

is edited to:

"dependencies": {
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-beta7"
  },

After saving the changes, you have to restore the dependencies. One way is to navigate with terminal (CMD) to the ProjectName/src/ProjectName/ folder (where the project.json file is located), and execute the

dnu restore

command. Hopefully it will request the new dependencies successfully, and you are ready to go.

PS.: I didn't try to run with x64 setup, since free/shared apps might(?) not be compatible with 64 bit platform setup. Feel free to correct me if I'm wrong about it.




回答2:


I had this error after upgrading a project from beta-5 to beta-8 when trying to run it in IIS Express. I was able to fix it by removing this line in wwwroot\web.config:

<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />

It must have been included in earlier versions of the project template and is presumably incompatible with the new request pipeline, but I haven't been able to find any documentation confirming this.



来源:https://stackoverflow.com/questions/32387052/upgrading-vs2015-to-asp-net-5-beta7-i-get-could-not-load-file-or-assembly-dnx-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!