0

I am build a dotnet core APIm which has SSL enabled. When I try to run I get the following error:

An error occurred attempting to determine the process id of dotnet.exe which is hosting your application. One or more errors occurred.

I have looked at countless pages (StackOverflow and others) that talk about this issue, and I understand the main reasons it can happen. But... I am almost certain none of them are my issue.

Firstly, when I turn off SSL and try to run without it still errors. Secondly, when I go through a process of "repairing" or reinstalling different dotnet core/iis express things it works. After working for some time, it will stop (I think possibly when Visual Studio is closed).

I have been unable to find any pattern as to when it starts working, but I believe it stops when Visual Studio 2015 closes.

Here are a few things I do, which may or may not get it temporarily working:

  • Repair IIS, giving me a https certificate for localhost
  • Open firefox or edge with the SSL address (after running without debug) to make sure it has certificate (or certificate exemption)
  • Repair/uninstall/reinstall dotnet core
  • Remove IIS Express files from local user

Please could somebody possibly give me either some suggestions for what it could be, or steps to help find out what the specific issue is?

Alternatively some kind of work around that I can use until we upgrade to Visual Studio 2017?

Additional information:

  • I sometimes use a VPN

  • project.json

 {
   "dependencies": {
  "Microsoft.NETCore.App": {
    "type": "platform",
    "version": "1.1.0"
  },
  "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-*",
  "Microsoft.Extensions.Logging.Console": "1.1.0",
  "Microsoft.AspNetCore.Diagnostics": "1.1.0",
  "Microsoft.AspNetCore.Mvc": "1.1.0",
  "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
  "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
  "Microsoft.EntityFrameworkCore": "1.1.0",
  "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
  "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.1.0",
  "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
  "Microsoft.Extensions.Configuration.Json": "1.1.0",
  "AutoMapper": "5.2.0",
  "Swashbuckle": "6.0.0-beta902",
  "Microsoft.Extensions.Logging.Debug": "1.1.0",
  "Microsoft.IdentityModel.Tokens": "5.1.2",
  "Microsoft.AspNetCore.Authentication.JwtBearer": "1.1.0",
  "OpenIddict": "1.0.0-*",
  "OpenIddict.EntityFrameworkCore": "1.0.0-*",
  "OpenIddict.Mvc": "1.0.0-*",
  "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0",
  "Microsoft.AspNetCore.Server.Kestrel.Https": "1.0.1",
  "AspNet.Security.OAuth.Validation": "1.0.0-*" 
   },

   "tools": {
  "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-*"
   },

   "frameworks": {
  "netcoreapp1.0": {
    "imports": [
   "dotnet5.6",
   "portable-net45+win8"
    ]
  }
   },

   "buildOptions": {
  "emitEntryPoint": true,
  "preserveCompilationContext": true,
  "xmlDoc": true
   },

   "runtimeOptions": {
  "configProperties": {
    "System.GC.Server": true
  }
   },

   "publishOptions": {
  "include": [
    "wwwroot",
    "web.config",
    "appsettings.json",
    "appsettings.production.json",
    "appsettings.development.json",
    "appsettings.labs.json",
    "Resources\\testCert.pfx",
    "Resources\\SiteWildcard.pfx"
  ]
   },

   "scripts": {
  "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
   }
 }
  • launchSettings.json

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "https://localhost:44345/",
      "sslPort": 44345
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "App.Api": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}
Andy Jones
  • 829
  • 11
  • 14
  • Possible duplicate of [An error occurred attempting to determine the process id of dotnet.exe which is hosting your application. One or more error occured](https://stackoverflow.com/questions/40965442/an-error-occurred-attempting-to-determine-the-process-id-of-dotnet-exe-which-is) – Michael Freidgeim Jun 10 '17 at 11:40

2 Answers2

1

I think I've just figured out what it is... It is happening only when the VPN is active. If I disconnect the VPN it works again. I don't know a solution of how to get it to work whilst the VPN is active, but I am happy enough with the work around for now.

This may come in useful in future to anybody else who has been stuck in the same position. For me the confusion of it sometimes working and sometimes not is because I have to activate and deactivate the VPN to connect to certain things.

Andy Jones
  • 829
  • 11
  • 14
1

https://support.microsoft.com/en-us/help/3180222/warnings-about-an-untrusted-certificate-after-you-install-visual-studio-2015-update-3

The above link worked for me.

You will need to open Windows PowerShell ISE from the windows search bar and enter the following command:

ipmo PKI
$name = [GUID]::NewGuid()
$cerFile = "$env:TEMP\$name.cer"
$certs = Get-ChildItem Cert:\LocalMachine\My -DnsName localhost -SSLServerAuthentication | ? {($_.FriendlyName -eq 'IIS Express Development  Certificate') -and ($_.SignatureAlgorithm.FriendlyName -ieq 'sha256RSA') -and ($_.EnhancedKeyUsageList.Count -eq 1)}
if ($certs.Count -eq 0)
{
Write-Error 'Cannot find any SHA256 certificate generated by IIS Express.   Please make sure that the latest version of IIS Express is installed.'
}
else
{
foreach ($cert in $certs)
{
    Export-Certificate -Cert $cert.PSPath -FilePath $cerFile -Type CERT |    Out-Null
    Import-Certificate -FilePath $cerFile -CertStoreLocation    Cert:\CurrentUser\Root | Out-Null
    Remove-Item $cerFile -Force
}
Write-Host 'Successfully installed the certificate to Trusted Root Certification Authorities of the current user.'
}

If the above code doesn't work just go to the link and copy it. You will then receive a warning message, click yes for that. Next use windows search to search for mmc to open up the Microsoft Management Console.

You can then follow the rest from the website. Hope it helps

Terry Tan
  • 11
  • 1