Search code examples
c#.net-assemblyassembly-loadingresource-dll

Load resource DLL with ResolveEventHandler


I have a handler to help resolve DLLs via ResolveEventHandler. But when I have this handler I get an error about resources DLL. Which I even don't see on my PC (though I have instances of this DLL for other cultures like es-ES, de-De, ...):

FileNotFoundException: Could not load file or assembly 'Microsoft.Data.Tools.Schema.Sql.resources, Version=15.0.0.0, Culture=en-US, PublicKeyToken=b03f5f7f11d50a3a'

When I run w/o the handler I see the following assembly loaded:

Microsoft.Data.Tools.Schema.Sql, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

What should I do in the handler or in somewhere else to resolve this resources DLL?


Solution

  • Ups, have just found an answer. I added the following check inside the handler:

    if (File.Exists(dllPath))
    {
         return Assembly.LoadFrom(dllPath);
    }
    else
    {
        return null;
    }