.NET参考"复制本地"根据海关总署的内容真/假存在套装海关总署、套装、根据、存在

2023-09-02 20:47:29 作者:洇.

我们有一个非常有趣的问题,一个双赢的窗体项目。它已经解决了。我们知道发生了什么,但我们要明白为什么会发生。这可以帮助其他人在谁也有类似的问题的未来。

We had a very interesting problem with a Win Forms project. It's been resolved. We know what happened, but we want to understand why it happened. This may help other people out in the future who have a similar problem.

本的WinForms项目不合格2客户的电脑。错误是一个不起眼的kernel.dll错误。该项目于3其他电脑精跑。

The WinForms project failed on 2 of our client's PCs. The error was an obscure kernel.dll error. The project ran fine on 3 other PCs.

我们发现,一个.DLL(log4net.dll - 一个非常流行的开源日志库)从我们的发布文件夹中缺少。这是previously在我们的发布文件夹中。为什么它在这个最新版本中缺少?

We found that a .DLL (log4net.dll - a very popular open-source logging library) was missing from our release folder. It was previously in our release folder. Why was it missing in this latest release?

据失踪,因为我必须对使用log4net.dll我开发中安装了一个程序,它被添加到全局程序集缓存。

It was missing because I must have installed a program on my Dev box that used log4net.dll and it was added to the Global Assembly Cache.

当我检查log4net.dll解决方案的参考,他们被改为复制本地= FALSE。他们一定会自动改变,因为log4net.dll是present在我的GAC。

When I checked the solution's references for log4net.dll, they were changed to "copy local=FALSE". They must have changed automatically because log4net.dll was present in my GAC.

这是我的问题开始的地方:

为什么我的log4net.dll参考得到复制本地= TRUE改变为复制本地= FALSE?我怀疑这是因为它被添加到我的GAC被其他程序。

Why did my reference for log4net.dll get changed from COPY LOCAL = TRUE to COPY LOCAL = FALSE? I suspect it's because it was added to my GAC by another program.

我们怎样才能prevent这种情况再次发生?目前的情况是,如果我安装了使用公共库一个软件,并将其添加到我的GAC,那么我的前哨淋巴结引用该DLL会从复制本地TRUE为FALSE。

How can we prevent this from happening again? As it stands now, if I install a piece of software that uses a common library and it adds it to my GAC, then my SLNs that reference that DLL will change from Copy Local TRUE to FALSE.

推荐答案

。因为本地副本将永远不会被使用,海关总署总是首先搜索。离开它不变,将造成重大的混乱,你会觉得你是在使用本地副本,但是得到另一个代替。更改它会导致混乱也是如此,如果你没有注意到它,这或许已经解决了消息框,在解决方案加载时间。

That happened because it doesn't make any sense to have Copy Local = True if an assembly is installed in the GAC. Because that local copy will never be used, the GAC is always searched first. Leaving it unchanged would cause major confusion, you'd think you are using the local copy but get another one instead. Changing it causes a confusion too, if you don't notice it, that could perhaps have been addressed with a message box at solution load time.

log4net的是一个麻烦制造者,也有太多的版本,在野外没有任何部署过程,确保这些版本不咬对方。 Apache的东西显然只是不想解决,离开它由程序员来代替。有了这样采取log4net的依赖,并做一些事情的感知DLL地狱风险的产品有些不可避免的。给你的回报DLL地狱问题。

Log4net is a troublemaker, there are way too many versions in the wild without any deployment procedure that ensures that those versions don't bite each other. Something Apache apparently just didn't want to address, leaving it up to the programmer instead. Having products that take a dependency on Log4net and do something about the perceived DLL Hell risk is somewhat inevitable. Giving you a DLL Hell problem in return.

没有干净简单的答案,超出意识到什么是安装在您的计算机上。考虑张贴到connect.microsoft.com索要警告时,Visual Studio会自动更新复制本地属性。这是一个合理的要求。

No clean simple answers, beyond being aware what's installed on your machine. Consider posting to connect.microsoft.com to ask for a warning when Visual Studio automatically updates the Copy Local property. It is a reasonable ask.

 
精彩推荐
图片推荐