Utilizing a .NET Core 2.2 NuGet library on .NET Core 3.0, but throwing an exception from being unable to find an assembly

1

Right now I'm using OpenTK through NuGet. It works fine on my .NET Core 2.2 project. However I can't get a WinForms component ported over to .NET Core 2.2. It does however work with .NET Core 3.0.

Therefore I want to upgrade to .NET Core 3.0 and get all of the upgrades that come with the upgrade. So far everything has upgraded perfectly fine except the OpenTK library on NuGet does not want to work with .NET Core 3.0.

Right now the following configurations work:

  • Project A (.NET Core 3.0) - depends on C

  • Project B (.NET Core 2.2) - depends on C

  • Project C (.NET Core 2.2) - class library

This works, however I'm a bit nervous with having project A being on .NET Core 3.0 in case I'm doing some bad mix and match and will cause something to accidentally blow up later on. If this is fine, let me know.

However if I change project C to .NET Core 3.0, then I get:

Project C is not compatible with netcoreapp2.2 (.NETCoreApp,Version=v2.2). Project C supports: netcoreapp3.0 (.NETCoreApp,Version=v3.0)

I assume this doesn't work because the class library (project C) is on a newer version and this means project B (on 2.2) would have trouble pulling in the 3.0 stuff.

The problem here is that I can't move project B to .NET Core 3.0 right now because one library throw this exception when I try to run it:

System.TypeInitializationException: 'The type initializer for 'OpenTK.DisplayDevice' threw an exception.'

Inner Exception

FileLoadException: Could not load file or assembly 'Microsoft.Win32.SystemEvents, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)

Is this something that has a trivial fix? I would like to move project B to .NET Core 3.0 but this issue above is standing in my way.

If it helps, OpenTK.dll is properly placed in the output directory. There is also a Microsoft.Win32.SystemEvents.dll in the output directory too. Is it possible that one of them is being bundled with OpenTK and it's outdated? Or is what I said here wrong?

c#
.net
.net-core
opentk
asked on Stack Overflow May 15, 2019 by Water

1 Answer

1

Because .NET Core 3.0 is also a preview, the following command with the NuGet Package Manager fixes it:

Install-Package Microsoft.Win32.SystemEvents -Version 4.6.0-preview.19073.11
answered on Stack Overflow May 15, 2019 by Water

User contributions licensed under CC BY-SA 3.0