I want to migrate my project in .NET Framework 4.0 to .NET Core 2.2. But I have an error in my program execution.
My project wants to load a .dll with the Assembly
class, it's working fine with .NET Framework 4.0 but not with .NET Core 2.2. It's throwing a n exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
using System.Reflection; // Assembly class
var pathToDll = "../../../../";
var asm = Assembly.LoadFrom(pathToDll);
var callingProgObject = asm.GetType("RandomType.CallingProg");
MethodInfo method = callingProgObject.GetMethod("MethodInDll");
var input = new InputForDll();
method.Invoke(callingProgObject, new object[] {input}); // <-------- error
I need to import one package compatible for .NET Core 2.2 similar to System.Windows.Forms
of .NET Framework 4.0?
My NuGet packages installed in Solution:
Not duplicate of How to use System.Windows.Forms in .NET Core class library