I'm migrating a .NET application to .NET Core, and one of the tasks that the app needs to do, is to enumerate assemblies the .NET Global Assembly Cache (yes, I know my .NET Core app itself doesn't use the GAC, but one of the purposes of my app is to create an inventory of what is in the full .NET Framework GAC)
Any method that I try to P/Invoke in the Fusion.dll
gives me the same error:
Unhandled Exception: System.DllNotFoundException: Unable to load DLL 'Fusion.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Code example:
class Program
{
static void Main(string[] args)
{
GacUtility.CreateAssemblyCache(out var x, 0);
}
}
public class GacUtility
{
[DllImport("Fusion.dll")]
public static extern int CreateAssemblyCache(out object asmCache, int reserved);
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
</Project>
NB: I know that correct signature of CreateAssemblyCache
expects an IAssemblyName
and I have that right in my code, which gives me the same error. I'm using object
above to simplify a reproduceable example.