如何改变在.NET中引用的加载路径? [英] How to change the loading path of references in .NET?

查看:131
本文介绍了如何改变在.NET中引用的加载路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想这样的设置:

+- /ApplicationFolder
  -- App.exe
  -- Core.dll
  -- AnotherShared.dll
  +- /PluginsFolder
    -- plugin1.dll
    -- plugin2.dll

但由于plugin1.dll引用Core.dll和Shared.dll当我编译应用程序它滴Copy.dll和Shared.dll,以插件的副本文件夹好,如果我删除它们没有关系'T工作了。

But because plugin1.dll references to Core.dll and Shared.dll when I compile the application it drops a copy of "Copy.dll" and "Shared.dll" to plugins folder as well and if I remove them it doesn't work any more.

我该如何解决这个问题呢?

How can I solve this problem?

推荐答案

当你创建一个AppDomain,您可以定义加载程序集的路径。设置的 AppDomainSetup.PrivateBinPath ,并传递给AppDomain.Create域。

When you create an AppDomain you can define a path for loading assemblies. Set AppDomainSetup.PrivateBinPath and pass to AppDomain.Create domain.

使用一个AppDomain是插件是一个好主意(允许不同的CAS和卸载)。

Using an AppDomain is a good idea for plugins (allows different CAS and unloading).

要避免VS /于引用的属性的MSBuild复制引用的程序集到输出目录,将复制本地设置为false。

To avoid VS/msbuild copying referenced assemblies to the output directory, change "Copy Local" to false in the properties of the reference.

这篇关于如何改变在.NET中引用的加载路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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