如何更改.NET中引用的加载路径?

编程入门 行业动态 更新时间:2024-10-25 22:36:18
本文介绍了如何更改.NET中引用的加载路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想要一个这样的设置:

I want a setup like this:

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

但是,因为plugin1.dll引用Core.dll和Shared.dll,当我编译应用程序时会丢弃一个Copy.dll和Shared.dll到plugins文件夹以及如果我删除它们不起作用。

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.

我如何解决这个问题?

推荐答案

创建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中引用的加载路径?

本文发布于:2023-11-10 10:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1575129.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路径   如何更改   加载   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!