CLR在运行时使用的dll [英] dll used by CLR at runtime

查看:54
本文介绍了CLR在运行时使用的dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个引用.NET DLL的C#应用​​程序.
如果此DLL同时存在于我的应用程序的 bin 目录和GAC中,则CLR将在运行时选择哪一个?如果GAC具有最新版本,是否使用该版本代替 bin 中存在的版本?

I've got a C# application which refers to a .NET DLL.
If this DLL is present both in my application's bin directory and GAC, then which one will be picked up by the CLR at runtime? If GAC has the latest version, would that version be used instead of the one present in bin?

以及如何强制CLR始终使用我的 bin 中的那个而不是GAC?

And how do I force the CLR to always use the one in my bin instead of GAC?

根据MSDN :

CLR检查全局程序集缓存,配置文件中指定的代码库以及然后检查应用程序的目录和子目录.

The CLR checks the global assembly cache, codebases specified in configuration files, and then checks the application's directory and subdirectories.

那么,这是否意味着它首先考虑了GAC?
谢谢.

So, does that mean it looks into GAC first?
Thanks.

推荐答案

您通过在GAC中不使用CLR来强制CLR 使用GAC中的程序集副本.通过重命名DLL或在项目中引用它之前更改其[AssemblyVersion]即可轻松完成.跳过此操作会调用讨厌的运行时异常,否则称为DLL Hell.

You force the CLR to not use a copy of an assembly in the GAC by not having it in the GAC. Simple to do by renaming the DLL or by changing its [AssemblyVersion] before referencing it in your project. Skipping this invokes nasty runtime exceptions, otherwise known as DLL Hell.

这篇关于CLR在运行时使用的dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆