Reputation: 752
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 want 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 the FileLoadException
with the message Could not load file or assembly 'LibName, Version=3.0.4.5, Culture=neutral, PublicKeyToken=null'
.
Is there a missing package in the project?
try
{
var pathDll = Path.Combine(path, "LibName.dll");
Assembly.LoadFrom(pathDll);
}
catch (FileLoadException ex)
{
throw ex;
}
My NuGet packages installed in Solution:
Upvotes: 1
Views: 280
Reputation: 164
I'm also calling assembly this way in .NET Core 2.1 and it works. Did you check path if it's correct? If path is relative, try to use absolute one - in .NET Core path of executable is a bit different when starting from Visual Studio.
By the way, consider using "throw" instead of "throw ex" in catch block, if you want to keep stack trace.
Upvotes: 1