简体   繁体   English

使用 ResolveEventHandler 加载资源 DLL

[英]Load resource DLL with ResolveEventHandler

I have a handler to help resolve DLLs via ResolveEventHandler .我有一个处理程序来帮助通过ResolveEventHandler解析 DLL。 But when I have this handler I get an error about resources DLL.但是当我有这个处理程序时,我收到关于资源 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, ...):我什至在我的电脑上都看不到(尽管我有这个 DLL 的实例,用于其他文化,如 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' FileNotFoundException:无法加载文件或程序集 'Microsoft.Data.Tools.Schema.Sql.resources,版本 = 15.0.0.0,文化 = 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 Microsoft.Data.Tools.Schema.Sql,版本=15.0.0.0,文化=中性,PublicKeyToken=b03f5f7f11d50a3a

What should I do in the handler or in somewhere else to resolve this resources DLL?我应该在处理程序或其他地方做什么来解决这个资源 DLL?

Ups, have just found an answer. ups,刚刚找到答案。 I added the following check inside the handler:我在处理程序中添加了以下检查:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM