简体   繁体   English

CLR 如何从程序集中加载文件?

[英]How does CLR load a file from an assembly?

Below is a multifile assembly consisting of two managed modules, one with a manifest:下面是一个多文件程序集,由两个托管模块组成,一个带有清单: 在此处输入图像描述

so RUT.netmodule(RUT stands for rare used types) is a file(.netmodule) that's part of the assembly.所以 RUT.netmodule(RUT 代表罕见的使用类型)是一个文件(.netmodule),它是程序集的一部分。

Let's say my client application references a type from RUT.netmodule and MultiFileLibrary.dll is a strong name assembly and it is installed in GAC.假设我的客户端应用程序引用了RUT.netmodule中的一个类型, MultiFileLibrary.dll是一个强名称程序集,它安装在 GAC 中。 Because RUT.netmodule doesn't physically reside in MultiFileLibrary.dll , so GAC won't have RUT.netmodule .因为RUT.netmodule在物理上并不驻留在MultiFileLibrary.dll中,所以 GAC 不会有RUT.netmodule

so my question is, maybe CLR is configured to check application's base directory to look for RUT.netmodule after it knows that the referenced type is in a different module file.所以我的问题是,也许 CLR 被配置为检查应用程序的基目录以在知道引用的类型在不同的模块文件中之后查找RUT.netmodule But it also means that RUT.netmodule have to always in application's base directory, which sounds strange to me as if I have mutiple applications then I need to have multiple RUT.netmodule in their base directory.但这也意味着RUT.netmodule必须始终位于应用程序的基本目录中,这对我来说听起来很奇怪,好像我有多个应用程序然后我需要在它们的基本目录中拥有多个RUT.netmodule Is a way to "install" RUT.netmodule in GAC or when MultiFileLibrary.dll is installed in GAC, any .netmodule files are also copied into GAC?是否有一种在 GAC 中“安装” RUT.netmodule的方法,或者当在 GAC 中安装MultiFileLibrary.dll时,任何 .netmodule 文件也会被复制到 GAC 中?

I have never working with multi-file assemblies but as far as I can tell you should be able to sign the .netmodule by using the assembly linker tool (al.exe).我从未使用过多文件程序集,但据我所知,您应该能够使用程序集 linker 工具 (al.exe) 对 .netmodule 进行签名。 The documentation contains a small quote which might be relevant:文档包含一个可能相关的小引号:

How to: Sign an assembly with a strong name如何:使用强名称签署程序集
... ...

  • By using the Assembly Linker (Al.exe) to link a .NET Framework code module (a .netmodule file) with a key file.通过使用程序集 Linker (Al.exe) 将 .NET 框架代码模块(.netmodule 文件)与密钥文件链接。

My guess is that even when you place the assembly in GAC it will still reference the .netmodule and it should work if the .netmodule is signed.我的猜测是,即使您将程序集放在 GAC 中,它仍然会引用 .netmodule 并且如果 .netmodule 已签名,它应该可以工作。 Hope this information helps you.希望这些信息对您有所帮助。

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

相关问题 如何使用XamlReader从程序集中的Xaml文件加载? - How does use XamlReader to load from a Xaml file from within the assembly? 如果给定的程序集是正确的,CLR如何知道? - How does the CLR know which if the given assembly is the correct one? 从C#/。NET程序集中,如何加载C ++ / CLR DLL并加载非托管DLL? - From a C#/.NET assembly, how do I load a C++/CLR DLL which loads an unmanaged DLL? 如何让CLR知道从GAC中选择哪个程序集? - How to let CLR know which assembly to pick from GAC? Sql 服务器 CLR 加载组件失败 - Sql Server CLR load assembly failed 了解 CLR/System.IO.FileNotFoundException “无法加载文件或程序集......或其依赖项之一” - understanding CLR/System.IO.FileNotFoundException "Could not load file or assembly ... or one of its dependencies" Assembly.Load(byte [])如何工作? - How does Assembly.Load(byte[]) work? 从资源加载的程序集引发无法加载文件或程序集 - Assembly loaded from Resources raises Could not load file or assembly 更好地查询数据库或将表数据加载到CLR程序集中的对象中? - Better to query DB or to load table-data into object in CLR assembly? 无法使用/ clr选项从Visual C ++项目加载CLR - Unable load CLR from Visual C++ project with /clr option
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM