如何让 Visual Studio 从 bin 运行程序集文件(依赖项)?

发布于 2024-09-09 06:51:25 字数 489 浏览 6 评论 0原文

我有一个由多个项目组成的解决方案,这些项目彼此之间具有各种依赖关系。当我构建项目/解决方案时,它会按应有的方式在 Project\bin 文件夹中创建 DLL 程序集文件。但是当我运行该程序时,它将所有内容复制到临时文件文件夹并从那里运行:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\ApplicationName

因此,现在 bin 文件夹和运行该项目的临时文件文件夹中的每个项目都有相同的 DLL 文件。问题是我在几个地方硬编码到我的项目中的 bin 目录的引用,因此当它查看那里时,它返回时会出现 DLL 混淆并出现错误。如何让 Visual Studio 从原始 bin 目录运行程序集文件,而不是复制它们并从临时文件运行它们?

PS 请不要告诉我更改硬编码 - 有原因使它必须保持原样;这就是为什么我想弄清楚如何逃离垃圾箱。

谢谢

I have a solution made up of multiple projects which have various dependencies on each other. When I build the project/solution, it creates the DLL assembly files in the Project\bin folder(s) as it should. But when I run the program, it copies everything to the temporary files folder and runs it from there:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\ApplicationName

So now there are identical DLL files for each project in the bin folders and in the temporary files folder, where it's being run from. The problem is that I have references to the bin directory(s) hardcoded into my projects in a couple places, so when it looks there, it comes back with a DLL mix-up and errors out. How can I get Visual Studio to run the assembly files from the original bin directory(s) instead of duplicating them and running them from the temporary files?

P.S. Please don't tell me to change the hardcoding - there are reasons why it has to stay as it is; that's why I'm trying to figure out how to run from the bin.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

樱娆 2024-09-16 06:51:25

这称为卷影复制,是一项设计功能。特别是对于 ASP.NET 站点,它允许在不卸载应用程序域的情况下更新域程序集,这对于设计为连续运行的 ASP.NET 站点非常重要。我真的建议保留它,并重新评估使用 \bin 目录的要求。

如果您确实想要禁用卷影复制,请将以下内容添加到您的 web.config 文件中:

<hostingEnvironment shadowCopyBinAssemblies="false" />

执行上述操作的副作用是,\bin 目录中的程序集将在应用程序的生命周期内被锁定。

This is known as Shadow Copying, and its a design feature. Particularly for ASP.NET sites, it enables domain assemblies to be updated without unloading the application domain, which is important for ASP.NET sites which are designed to run continuously. I would really recommend leaving it on, and re-assessing the requirement for use of the \bin directory.

If you really want to disable shadow copying, add the following to your web.config file:

<hostingEnvironment shadowCopyBinAssemblies="false" />

The side-effect of doing the above, is that your assemblies in your \bin directory will be locked during the lifetime of the application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文