dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.54k stars 10.05k forks source link

HTTP Error 500.31 - ANCM Failed to Find Native Dependencies #14443

Closed ghosttie closed 5 years ago

ghosttie commented 5 years ago

I upgraded an ASP.NET Core 2.2 application to 3.0.

It works fine in the development environment, but when I publish it to the test environment I get a HTTP Error 500.31 - ANCM Failed to Find Native Dependencies error.

Annotation 2019-09-25 170442

The documentation says that this error most commonly means that the Microsoft.NETCore.App or Microsoft.AspNetCore.App runtime isn't installed but I installed the ASP.NET Core/.NET Core: 3.0 Runtime & Hosting Bundle, and I'm not sure what else I can do.

The Event Viewer/stdout logs this:

An assembly specified in the application dependencies manifest (ETR Lite.deps.json) was not found: package: 'Microsoft.Data.SqlClient', version: '1.0.19249.1' path: 'runtimes/win/lib/netcoreapp2.1/Microsoft.Data.SqlClient.dll'

I don't understand why it's looking under netcoreapp2.1 for a netcoreapp3.0 application, and why it can't find the dependency even though it's present in the refs folder.

If I manually put that DLL in the folder it's looking for it I get

An assembly specified in the application dependencies manifest (ETR Lite.deps.json) was not found: package: 'System.Runtime.Caching', version: '4.5.0' path: 'runtimes/win/lib/netcoreapp2.0/System.Runtime.Caching.dll'

which I understand even less.

The dotnet --info output is:

It was not possible to find any installed .NET Core SDKs Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from: https://aka.ms/dotnet-download

Host (useful for support): Version: 3.0.0 Commit: 7d57652f33

.NET Core SDKs installed: No SDKs were found.

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

I tried installing the SDK but it didn't make any difference.

davidfowl commented 5 years ago

What's installed on your production environment? Did you install the new hosting bundle?

ghosttie commented 5 years ago

Yes, I installed the 3.0 hosting bundle and dotnet --info shows that Microsoft.NETCore.App 3.0.0 and Microsoft.AspNetCore.App 3.0.0 are installed

tjs-shah commented 5 years ago

I ran into same issue: With Framework Dependent publish I was getting 500.0 - ACNM In-Process Handler Load Failure 500.31 - ACNM Failed to find Native Dependencies

After granting IIS_USERS Read/Write permission on the publish folder mapped to IIS site resolved the issue for me.

ghosttie commented 5 years ago

Thanks @shah-123 but that didn't fix it

ghosttie commented 5 years ago

I've figured it out!

The main project had project references to other projects that had spaces in their package ids, which somehow kept them from being published correctly (even though there was no error at publish time).

Although there's a simple workaround (remove the spaces) I think this should be fixed, because it worked in previous versions, the error message doesn't lead to a solution, and the package id was set automatically when the project was created so it should have been set to a valid value.

jkotalik commented 5 years ago

@ghosttie If this is behavior that changed between 2.2 and 3.0, I'd recommend filing an issue in an appropriate repository. I'm uncertain where the issue actually is, maybe with either the dotnet sdk (https://github.com/dotnet/sdk) or nuget (https://github.com/NuGet)?

This doesn't seem like an ANCM issue at all. Even though the error you got was an ANCM error, it's really a red-herring here. I'm going to close this for now, feel free to reopen if you believe there is an issue with AspNetCore.

icesasoftcorp commented 5 years ago

can you help me what you mean with spaces spaces in their package identifiers

rmegal commented 5 years ago

I have the same problem. I was able to recreate it starting with "dotnet new webapi". I published this to IIS and was able to use it. I then run "dotnet add package Microsoft.EntityFrameworkCore.SqlServer" and publish this. Now I get: HTTP Error 500.31 - ANCM Failed to Find Native Dependencies. aspdotnet.zip

rmegal commented 5 years ago

I discovered the problem goes away if I'm specific about the --framework. See the deploy.ps1 file in my previous attachment. I was running:

&dotnet publish --output $targetdir --configuration release

The problem goes away if I run this instead:

&dotnet publish --output $targetdir --configuration release --framework netcoreapp3.0

The output of dotnet --list-sdks is: 3.0.100 [C:\Program Files\dotnet\sdk]

analogrelay commented 5 years ago

@rmegal please file a new issue as this error can have numerous causes. Include your repro app and steps to reproduce the problem.

@icesasoftcorp I believe what @ghosttie meant was that the project referenced other projects with spaces in the name.