简体   繁体   English

动态加载需要GAC程序集的组件,而该程序集实际上是不可用的?

[英]Dynamically loading an assembly which expects GAC assemblies which are not actually available?

What happens if an application tries to load an assembly which has references to assemblies in the GAC and these assemblies are not available on the machine? 如果应用程序尝试加载引用了GAC中的程序集的程序集并且这些程序集在计算机上不可用,会发生什么情况?

Basically I want to rely on assembly loading succeeding to assume that the referenced assemblies are available on the end users machine. 基本上,我想依靠程序集加载成功假设引用的程序集在最终用户计算机上可用。 Am I being dense? 我很稠密吗?

If the runtime isn't able to load a required assembly, it will throw an exception (doesn't matter if you try to load it at startup or dynamically via Assembly.Load() ). 如果运行时无法加载所需的程序集,则它将引发异常(无论您是尝试在启动时还是通过Assembly.Load()动态加载它都没有关系)。 So if you don't get an exception, you can expect the classes to be avaiable. 因此,如果没有异常,则可以期望这些类可用。

Basically I want to rely on assembly loading succeeding 基本上我想依靠程序集加载成功

It never pays to rely on something like this! 依靠这样的东西永远都不值得! Anyway, to answer your question, you'll get an exception. 无论如何,要回答您的问题,您将获得一个例外。 If an exception is not thrown then the dependent assemblies have been loaded. 如果未引发异常,则依赖的程序集已加载。 If an exception is thrown, then either they're not there, or some other problem has occurred. 如果抛出一个异常,那么他们要么是不存在,或出现其他问题。

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

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