Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Core RC2 applicationhost.config incompatible with ASP.NET .NET 4.6?

Given a solution containing two websites:

1) ASP.NET based on .NET 4.61

2) .NET Core RC2

After launching iisexpress for (2), MSVS updates the applicationhost.config to contain a few extra lines that appear to be incompatible with (1). This isn't noticed until iisexpress is first shutdown and then attempting to launch (1).

The incompatible lines are:

<section name="aspNetCore" overrideModeDefault="Allow" />

<add name="AspNetCoreModule" image="C:\Program Files (x86)\Microsoft Web Tools\AspNetCoreModule\aspnetcore.dll" />

<add name="AspNetCoreModule" />

When launching (1), a dialog appears stating "IISExpress failed to launch" and an event is written:

The Module DLL 'C:\Program Files (x86)\Microsoft Web Tools\AspNetCoreModule\aspnetcore.dll' could not be loaded due to a configuration problem. The current configuration only supports loading images built for a AMD64 processor architecture. The data field contains the error number. To learn more about this issue, including how to troubleshooting this kind of processor architecture mismatch error, see http://go.microsoft.com/fwlink/?LinkId=29349.

Possible solutions?

A) Removed the extra lines before launching (1), how to achieve that automatically?

B) Use a different applicationhost.config for each website, is there an environment variable to set this?

C) Directly fix the problem reported in the event log. Somehow it works when launches the .NET Core RC2 site so that's strange.

D) Use separate solution files that happen to be in different directories. This is not desirable as it is a fairly complex solution.

like image 793
crokusek Avatar asked May 28 '16 03:05

crokusek


2 Answers

A similar problem to this will happen if you create a solution with mixed .NET Core RC2 and ASP.NET < 5 projects, then upgrade to .NET Core 1.0. The ASP.NET projects will no longer run.

To fix, delete .vs\config\applicationhost.config and unload and reload the project/solution to force VS to regenerate it properly with . NET Core 1.0 settings, then any legacy .NET stuff will run.

I also figured out Event Viewer logs the exact command line that IIS Express is run with when you try to run it in VS, so you can grab that and stick it in a command prompt to get error output from IIS Express, especially useful if there's no Errors themselves in the Event Viewer.

like image 104
user169771 Avatar answered Sep 28 '22 10:09

user169771


Here's what worked--along the lines of suggestion (B):

1) To the add tag that specified the "image", add

preCondition="bitness32"

2) Add a location block if one does not already exist, specify remove:

 <location path="Your_NonCore_SiteName">
    <system.webServer>
      <modules>
        <remove name="AspNetCoreModule" />
      </modules>
    </system.webServer>
  </location>

Not sure why this works because bitness32 seems backwards to me (because the original error message said it was amd64).

Now both sites can be launched simultaneously and MSVS does not override these manual edits.

Use at own risk! Hoping for a better answer or improvement with next release.

like image 24
crokusek Avatar answered Sep 28 '22 11:09

crokusek