Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running MVC6 Beta8 app on IIS Express

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?

like image 518
Sergey Kandaurov Avatar asked Oct 15 '15 20:10

Sergey Kandaurov


3 Answers

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

like image 121
cygnim Avatar answered Sep 30 '22 09:09

cygnim


Here is how I resolved the problem:

  1. Download and install latest WebToolsExtentions from http://www.microsoft.com/en-us/download/details.aspx?id=49442
  2. Create a new ASP.NET5 Web Application project
  3. Copy your files from an old project to a new project

I could not figure out how to modify the existing project.

like image 29
Sergey Kandaurov Avatar answered Sep 30 '22 07:09

Sergey Kandaurov


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 beta7to beta8.

Hope this helps.

like image 23
Pedro Almeida Avatar answered Sep 30 '22 07:09

Pedro Almeida