2

I have a .NET Framework 4.6.1 console application and I am attempting to reference a .NET Core 2.0 assembly within it. Visual Studio lets me setup the reference, Intellisense seems OK with the classes and methods within the .NET Core assembly but it fails to run.

If I debug the app in Visual Studio, VS shows me this message:

The application is in break mode

Your app has entered a break state, but no code is currently executing that is supported by the selected debug engine (e.g. only native runtime code is executing).

If I start without debugging, I get this exception:

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at MyProject.Program.Main(String[] args)

Not sure what to make of this. I think I'm looking for an answer similar to this one but updated since this question is over 2 years old and the answer is no longer relevant to the current state of .NET Core.

Community
  • 1
  • 1
Raymond Saltrelli
  • 4,071
  • 2
  • 33
  • 52
  • 6
    You can't load a .net Core library on a Classic application, you can load a .net Standard library on both, Core and Classic – Gusman Dec 20 '17 at 15:47
  • 1
    Well, crap. Looks like I have to go convert my assembly to .NET Standard then. – Raymond Saltrelli Dec 20 '17 at 15:50
  • That's the idea behind .net Standard, to have a base code shareable between all the .net technologies, it's an improvement over PCL. But beware, referencing a .net Standard library adds a TON of references to .net Standard packages. – Gusman Dec 20 '17 at 15:51
  • Everything that @Gusman said is correct. You'll need to re-write your assembly as a .NET Standard one rather than .NET Core. The different ecosystems (Framework, Core, Xamarin, etc.) are implementations of the .NET Standard, so to target some code across all of them you need to create .NET Standard libraries. If you're unsure about the .NET Standard and how it fits, see these videos by Immo Landwerth https://www.youtube.com/watch?v=YI4MurjfMn8&list=PLRAdsfhKI4OWx321A_pr-7HhRNk7wOLLY – Jamie Taylor Dec 20 '17 at 17:34

0 Answers0