.NET build output using nuget "reference assemblies" instead of actual libraries: Reference assemblies should not be loaded for execution

0

I have a project that when I run it as a console application it works just fine. It gets the correct package references via nuget and works. I am trying to use Npgsql which is the root of the problem.

When I built my Azure cloud project that uses this library, the build output instead uses the "ref" version of System.Runtime.CompilerServices.Unsafe and System.ValueTuple instead. So when I go to run my app I get errors like this:

BadImageFormatException: Could not load file or assembly 'System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. 
Reference assemblies should not be loaded for execution.  They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)

This isn't a binding redirect problem. As you can see from the error "Reference assemblies should not be loaded for execution.", the issue is the build output is using reference assemblies, and not the actual libraries from the nuget package.

My project is using the new csproj style and uses "PackageReference" for Npgsql and the packages in question.

Is there some way to tell my csproj to never use "reference assemblies"?

Is there an option in msbuild to somehow change this?

c#
.net
npgsql
asked on Stack Overflow Jul 13, 2020 by Matt Watson

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0