试图确定承载您的应用程序的 DNX 进程的进程 ID 时出错

当我试图启动应用程序时,我得到了这个错误消息。

试图确定 DNX 的进程 id 时出错 进程托管您的应用程序

有办法解决这个问题吗?

35694 次浏览

Microsoft changed the hosting model as described in the release notes.

In project.json replace the dependency

"Microsoft.AspNet.Server.IIS": "1.0.0-beta7"

with

"Microsoft.AspNet.Server.Kestrel": "1.0.0-beta8"


In web.config in the handlers section remove every entry except

<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />

The complete web.config will look like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false" startupTimeLimit="3600"/>
</system.webServer>
</configuration>

RC1: While using RC1 I had the error after moving the solution folder. After deleting the bin and obj folders everything worked again.
As user764754 noted, simply restarting Visual Studio can also help.

It is possible to upgrade, i found i had to look through the new updated templates here.

Update your web.config in wwwroot to include:

<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false" startupTimeLimit="3600"/>

You will also need to change the way the project debugs using Kestrel by modifying your project.json:

"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"dependencies": {
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-beta8",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-beta8",
}

and modifying your hosting.ini

server=Microsoft.AspNet.Server.Kestrel

and adding this to the Configure method in startup.cs

// Add the platform handler to the request pipeline.
app.UseIISPlatformHandler();

adding these references should allow you to run the project.

When upgrading from beta7 -> beta8 I had this issue and the suggestions provided by Ben M and Domysee worked for me. However, one of my colleagues was still having problems running our project which targets dnxcore50 only. If you make sure you have run the following commands:

dnvm install 1.0.0-beta8 -r coreclr
dnvm install 1.0.0-beta8 -r coreclr -arch x86

It was the second command in particular that fixed it on his machine. You can also double-check this folder has a dnx.exe in it:

%userprofile%\.dnx\runtimes\dnx-coreclr-win-x86.1.0.0-beta8\bin

For me the problem was solved by closing down Visual Studio, deleting

project.lock.json

and starting Visual Studio again.

Edit: I was using RC1.

For what it's worth, this is a generic error message that could serve as a red herring to any number of issues where the httpPlatformHandler can't launch the given executable (dnx in this case).

In my case I received this error as a direct result of misunderstanding the launchSettings.json file. I was trying to enable the https endpoint for my application and mistakenly duplicated the sslport in my applicationUrl. As I understand it the applicationUrl should be the http hostname/port of the application and by filling in the sslPort it just configures the IIS Express environment to listen for https on the hostname given in the applicationUrl on the port provided in sslPort.

For example:

  "iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:44000",
"sslPort": 44300
}
}

Provides the following two endpoints on localhost.

  • Http over port 44400
  • Https over port 44300

If you were to have the same port in the applicationUrl and sslPort settings, you would receive the error associated with this thread.

This is true for me on RC1

Check web.config file for invalid entries. For example, having "entityFramework" tag there causes this problem for me.

I had this trouble when I'm toggling settings and have disabled the "Enable Anonymous Authentication" in the Project > Properties > Debug. Make sure that it is enabled. Close and relaunched the project then try again. Hope this helps.

I used RC1 and EF First Code Approach. Good idea to start investigation is to run project with option: "Start project without debbuging" (Ctrl+F5). Then I get more meaningful error for me: "The configuration section 'entityFramework' cannot be read because it is missing a section declaration." It didn't work for me because of web.config file.

  1. Update dnvm
  2. Change global.json sdk version as the dnvm's default
  3. No need to touch project.json or project.lock.json

I hit this problem due to the project config trying launch https://localhost instead of http. Right click on the webproject, under "Debug" and adjust "App URL" to be http instead of https. enter image description here

Another way to get around this was switching the launcher from "IIS Express" to "Web"

For other people having this problem, in cases in which the other solutions don't work - I found the answer in this thread: Forcing to use SSL: An error ocurred attempting to determine the process id of the DNX process hosting your application

I your project uses or enforces SSL run it without debugging (CTRL+F5) first, it will ask you to generate a local SSL cert, and after that debugging will work and the error will be gone.

There are just so many things that could cause this error. Here are a few that worked for me:

  1. Just delete the web.config in your wwwroot folder. It will get recreated correctly on compilation.
  2. If you are trying to use SSL and in your IIS Express and moving your SSL Cert to the Trusted Root Certification Authorities folder didn't work. In the Debug tab of the Properties of the project you are trying to run. Try unclicking the Enable SSL checkbox and then clicking it again to enable it and get a different port. You may have to do this a few times.

Assuming you are running IIS Express with SSL Enabled depending on your installation you will have to put your IIS Express Development Certificate(Issued To "localhost"/ Issued By "localhost") in either [Local Computer\Personal\Certificates] or [Local Computer\Trusted Root Certification\Certificates]. One of those should work. (Using Windows 10 + VS2015). HTH

In Visual Studio:

While following this tutorial I received a similar error.

First, I received the error: "An error occurred attempting to determine the process id of dotnet.exe..." I took the following steps.

  1. I started my application without debugging CTRL+F5.
  2. I was then presented with an option to accept a self-signed certificate for localhost.
  3. I followed the prompts and then I was able to visit my application using the AppUrl I copied over after enabling SSL in project debug settings.

While trying a few things to solve that error I also came across this error. "An error occurred attempting to determine the process id of the DNX process hosting your application"

Which was caused by having another instance of the application running.

I hope this answer helps someone.

I've just discovered one more problem that was causing this!

web.config in project root had some dodgy IIS URL rewrite rules to enforce HTTPS. Removing those rules solved the problem.

Another potential solution
For anyone playing with SSL settings, I found just changing the SSL port in the launchSettings.json file to another nearby port solved the problem.

FYI, I couldn't find anything on the machine using the original port, nor did I get a port in use error.

In my case in an asp net core 1.1, .net framework 4.5.2 project, the error did not refer to dnx since that is no more. Instead it referred to the project name exe. Another version of the error referred to simply being unable to connect to iis express.

The problem was the introduction of a canonical host name rewrite rule that tries to force all connections to have a host name that begins with www. e.g. redirecting gty.org to www.gty.org to conform to our ssl cert. This is fine in production but you can't force https://localhost:44347/ to begin with www and expect iis express to be able to handle it.

<rule name="CanonicalHostNameAddwww" enabled="true" stopProcessing="true">
<match url="(.*)" ignoreCase="true" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" negate="true" pattern="^www\." />
</conditions>
<action type="Redirect" url="http://www.{HTTP_HOST}{HTTP_URL}"  appendQueryString="false" redirectType="Permanent" />
</rule>

The solution was to comment out the rule when running in visual studio or add a condition:

<add input="{HTTP_HOST}" negate="true" pattern="^localhost" />