动态加载需要实际不可用的 GAC 程序集的程序集?
如果应用程序尝试加载引用 GAC 中的程序集的程序集,但这些程序集在计算机上不可用,会发生什么情况?
基本上,我想依赖程序集加载来成功假设引用的程序集在最终用户计算机上可用。我是不是很稠密?
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?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
依赖这样的东西永远不会有回报!无论如何,要回答你的问题,你会得到一个例外。如果未引发异常,则已加载依赖程序集。如果抛出异常,则要么它们不存在,要么发生了其他问题。
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.
如果运行时无法加载所需的程序集,它将引发异常(无论您尝试在启动时加载它还是通过
Assembly.Load()
动态加载它都没有关系)。因此,如果您没有遇到异常,则可以预期这些课程是可用的。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()
). So if you don't get an exception, you can expect the classes to be avaiable.