0

I found lots of posts about referencing a .NET Core project from 4.6.1, but I'm getting an error simply referencing a .NET Core 1.1 DLL directly from a 4.6.1 Winforms app. Strangely, it compiles fine, but gets this runtime error:

"Could not load file or assembly 'System.Runtime, Version=4.1.0.0...."

The 4.6.1 app runs fine until it gets to the class that's using the referenced assembly, then throws this error (doesn't even run that class's constructor).

My main requirement is that the .NET Core DLL needs to be cross-platform - it needs to run in Ubuntu.

The core DLL's project.json in its entirety:

{ "version": "1.0.0-*",

"dependencies": { "Microsoft.NETCore.App": { "type": "platform", "version": "1.1.0" },

"frameworks": { "netcoreapp1.1": { } } }

I'm not sure why this is happening - the core DLL is not referencing anything other than core - why does it make my 4.6.1 app start looking for System.Runtime? That's a framework assembly. And if it's something about the configuration of the Core DLL, why wouldn't it be a compile-time error?

Any help is much appreciated.

  • Buzz
1
  • .NET Core? Not possible. .NET Standard, yes. Please learn the differences before moving further. Commented Mar 6, 2017 at 17:09

1 Answer 1

2

If you want a library to be able to be run in both .NET Framework 4.6.1 and on Ubuntu using .NET Core, then that library should be targeting netstandard1.4 or lower. See the .NET Standard documentation for more information.

.NET Standard is the new "portable class libraries" that allow your libraries to be run on .NET Framework, .NET Core, Mono, UWP, etc - all the places where .NET code can be executed.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Eric. You say "1.4 or lower...". I assume that's the latest version that Linux .NET Core supports, is that correct? Where would I go to keep up with the supported versions for Linux?
I say "netstandard1.4 or lower" because you want to target .NET Framework 4.6.1. See the chart on this webpage: learn.microsoft.com/en-us/dotnet/articles/standard/library that shows that .NET Framework 4.6.1 can run libraries that target netstandard1.4 or lower. On Linux, .NET Core is the platform you will run on, and it supports netstandard1.0 - 1.6 currently. With 2.0 coming soon.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.