问题
I just updated to MVC6 Beta8. After a few hours fixing the code to compile again, I run into an issues that the app does not run under IIS Express. I'm getting this error message:
[TypeLoadException: Could not load type 'Microsoft.Dnx.Host.Clr.EntryPoint' from assembly 'Microsoft.Dnx.Host.Clr, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.] System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException) +303
[HttpException (0x80004005): Could not load type 'Microsoft.Dnx.Host.Clr.EntryPoint' from assembly 'Microsoft.Dnx.Host.Clr, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9922864 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +90 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +261
I know there were changes to the hosting architecture. But does this mean that we can't use IIS express anymore or it's just a matter of update or configuration change?
回答1:
There are a few breaking changes to the IIS/IIS Express hosting model that you need to account for when upgrading to beta8.
In your project.json file, remove these from dependencies:
- "Microsoft.AspNet.Server.IIS"
- "Microsoft.AspNet.Server.WebListener"
Add the following to your dependencies:
- "Microsoft.AspNet.Server.Kestrel"
- "Microsoft.AspNet.IISPlatformHandler
Finally, in your Startup.cs file, add the following to the Configure method:
app.UseIISPlatformHandler();
(I'm assuming app
is the name of your IApplicationBuilder, you can adjust accordingly).
This will add the new IISPlatformHandler to the pipeline and directs traffic to the Kestrel server, therefore bypassing IIS and the old Helios dnx host.
You can read up on this change in the announcements on Github
回答2:
Here is how I resolved the problem:
- Download and install latest WebToolsExtentions from http://www.microsoft.com/en-us/download/details.aspx?id=49442
- Create a new ASP.NET5 Web Application project
- Copy your files from an old project to a new project
I could not figure out how to modify the existing project.
回答3:
I had the same issue after upgrading to beta 8 and solved it by removing the following dependencies from project.json
:
"Microsoft.AspNet.Server.IIS": "1.0.0-beta7"
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta7"
And adding the following dependency:
"Microsoft.AspNet.Server.Kestrel": "1.0.0-beta8"
I also updated all the project references from beta7
to beta8
.
Hope this helps.
回答4:
Here is my way. Someone can find something usefull. I added this lines to my project.json:
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-beta8",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta8",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-beta8",
And I changed commands from:
"commands": {
"web": "Microsoft.AspNet.Hosting --config hosting.ini",
},
to this:
"commands": {
"web": "Microsoft.AspNet.Hosting server=Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000",
"kestrel": "Microsoft.AspNet.Server.Kestrel",
},
then dnu restore
Now you can run your asp.net application with dnx web
or dnx kestrel
command. Differences are described here: https://github.com/aspnet/Home/wiki/Servers
来源:https://stackoverflow.com/questions/33158073/running-mvc6-beta8-app-on-iis-express