.Net 代码库元素

标签 .net

我已经查看了其他几篇关于如何让 CLR 查找不在同一文件夹或可执行文件的任何子文件夹中的程序集的帖子,但我无法让它为我工作。 ClassLibrary1.dll 是一个未签名的程序集。示例显示:

<configuration> 
<runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
        <dependentAssembly> 
            <assemblyIdentity name="ClassLibrary1"/> 
            <codeBase version="1.0.0.0"                    
                href=file:///C:\somepath\subfolder\ClassLibrary1.dll"/> 
        </dependentAssembly> 
    </assemblyBinding> 
</runtime> 
</configuration> 

我创建了一个控制台应用程序,并将上面的内容和正确的路径放在它的配置文件中,但仍然收到一条消息,指出它找不到 ClassLibrary1.dll。我使用了 FUSLOGVW,它甚至没有检查 CodeBase 元素中提供的文件夹。有谁知道为什么这不起作用?

最佳答案

来自 MSDN :

If the assembly has a strong name, the codebase setting can be anywhere on the local intranet or the Internet. If the assembly is a private assembly, the codebase setting must be a path relative to the application's directory.

这意味着如果您不对程序集进行签名,那么它必须位于应用程序文件夹或应用程序文件夹的子文件夹中。如果您想将应用程序放在 c:\Program Files\MyApplication 中,而将程序集放在 c:\MyAssemblies 中,则必须对程序集进行签名。

关于.Net 代码库元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9688269/

相关文章:

.net - 保持 sql 数据库模式在开发人员之间同步

c# - 将 Dictionary(string, List<string>) 序列化为 xml

c# - ref struct 中不能使用 Yield 关键字?

c# - token 解密 RSA 适用于本地主机但不适用于服务器

c# - 如何自动创建用户备份?

c# - 返回整数和字符串

c# - 方法的类型参数与其外部类型相同

.net - 如何在 Azure Function v1 (.NET Framework) 中使用 Azure App Configuration 服务

.net - EF Code First - 删除迁移文件

c# - 为什么 C# 不推断我的泛型类型?