.NET Core RC2 applicationhost.config incompatible with ASP.NET .NET 4.6?
Asked Answered
C

3

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.

Corroborant answered 28/5, 2016 at 3:56 Comment(4)
A possible solution is to manually edit applicationHost.config so that the two web apps run in different application pools (.NET 4.6.1 app in a pool with CLR 4, and the ASP.NET Core one in a pool without CLR), and with separate module configuration to load that ASP.NET Core module only in the ASP.NET Core app.Achilles
@LexLi, I tried something similar to your advice by moving the 3rd one from default section Location="" to the specific Location of the core net and was able to get both sites running. But then if I rebuild and launch the Core site, MSVS re-adds the line to the Location="" area. I assume if the MSVS rewrite would occur if I broke out into separate app pools as well, correct? Because MSVS is writing the global modules section.Corroborant
There are also these "preConditions" in some of the dll lines. I tried adding bitness64 to the one its complaining about but it threw an error.Corroborant
I don't think precondition would help. Since VS tries to add the module to the config file, then instead of moving the tag, you should utilize <remove> tag to remove it in web.config level or use a location tag.Achilles
B
8

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.

Bot answered 8/7, 2016 at 16:27 Comment(2)
Yes this! The applicationhost.config in the .vs folder not in the Documents\IISExpress folder. Finally after 2 days of head banging. Much thanks!Quietly
I had this problem as well after having ridden the .NET Core roller coaster since Preview 6. Turns out co-locating these in the same solution was a bad idea for many reasons... lesson learned.Geronimo
C
2

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.

Corroborant answered 31/5, 2016 at 22:32 Comment(0)
S
0

This should be fixed by the latest tooling (VS 2015 Update 3 and DotNetCore.1.0.0-VS2015Tools.Preview2) https://www.microsoft.com/net/core#windows

AspNetCoreModule now has a proper installer for IIS Express (included in the new tooling).

Semiyearly answered 7/7, 2016 at 16:49 Comment(3)
Nope, still an issue for me.Bot
It looks like IIS Express still tries to load the RC2 module even after uninstalling it. The file itself is no longer there.Bot
I figured it out. Delete <SOLUTION DIR>\.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.Bot

© 2022 - 2024 — McMap. All rights reserved.