添加对 GAC 程序集的引用以递归方式复制非 GAC 相关程序集 (c# Visual Studio 2008)

发布于 2024-10-02 14:08:28 字数 878 浏览 0 评论 0原文

这是我的应用程序部署: c:\Program Files\Product\API.dll(在 Gac 中注册)
c:\Program Files\Product\ApiImpl1.dll(非 Gac)
c:\Program Files\Product\ApiImpl2.dll(非 Gac)
c:\ConsoleApplication\TestApi.exe

Api.dll 是实现“c:\Program Files\Product\”的应用程序的外观 Api.Dll 在 GAC 中注册,并具有 DLL 的程序集解析器,位于“c:\Program Files\Product\” Api.dll 同时引用 ApiImpl1.dll 和 ApiImpl2.dll。

问题是,当我在 ConsoleApplication 中添加对 Api.dll 的引用时,Visual Studio 将 ApiImpl1.dll 和 ApiImpl2.dll 重复复制到项目目标。 (虽然CopyLocal=False) 我通过浏览将引用添加到“c:\Program Files\Product\API.dll”

据我所知,我有几种解决方案:
1)在GAC中注册ApiImpl1.dll和ApiImpl2.dll(不可接受,我有Assembly Resolver)
2) 添加到“.Net Add Reference”注册表,“c:\Program Files\Product”(无法解决)
3)添加到“.Net Add Reference”注册表,“c:\windows\Assembly\gac_msil\Api.dll(解决了,但这是一个糟糕的解决方案)
4) 手动更改 ConsoleApplication.csproj 并删除 Api.dll Reference 的 HintPath 属性。 (不可接受,因为我会有很多客户会使用这个API)

This is my application deplyoment:
c:\Program Files\Product\API.dll (Registered in Gac)
c:\Program Files\Product\ApiImpl1.dll (Non Gac)
c:\Program Files\Product\ApiImpl2.dll (Non Gac)
c:\ConsoleApplication\TestApi.exe

Api.dll is Facade for Application which implemented "c:\Program Files\Product\"
Api.Dll is registered in GAC and has Assembly Resolver to DLLs which is located in "c:\Program Files\Product\"
Api.dll reference both ApiImpl1.dll and ApiImpl2.dll.

The problem is when in ConsoleApplication I add reference to Api.dll Visual Studio copies recusively the ApiImpl1.dll and ApiImpl2.dll to the project destination. (Although CopyLocal=False)
I add the reference by Browsing to "c:\Program Files\Product\API.dll"

As far as I know, I have several solutions:
1) Register ApiImpl1.dll and ApiImpl2.dll in GAC (Not acceptable, I have the Assembly Resolver for this)
2) Add to ".Net Add Reference" Registry, "c:\Program Files\Product" (Doesn't solve it)
3) Add to ".Net Add Reference" Registry, "c:\windows\Assembly\gac_msil\Api.dll (Solve it, but it is a bad solution)
4) Manually Change the ConsoleApplication.csproj and Remove HintPath attribute of Api.dll Reference. (Not acceptable, Because I will have a lot of customers which will use this API)

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

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

发布评论

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

评论(1

ぺ禁宫浮华殁 2024-10-09 14:08:28

您应该始终在 GAC 中拥有依赖于 GAC 的 dll……如果其中一个需要存在,那么其他的也需要存在。

问题是,虽然 Visual Studio 知道在哪里通过引用找到这些 dll 文件,但如果 dll 文件不在项目目录中(因此存在副本),则运行时的应用程序将不知道在哪里查找。

编辑
如果您有Assembly Resolver,是否有必要将API.dll放入GAC中?也许如果该 dll 不在 GAC 中,Visual Studio 就不会复制其他文件。我很确定根 DLL 位于 GAC 中,但依赖 DLL 不在 GAC 中。

You should always have GAC-dependent dlls in the GAC... if one needs to be there, so do the others.

The problem is that while Visual Studio knows where to find these dll files by the references, the application at runtime will not know where to look if the dll files aren't in the project directory (hence the copy).

EDIT
Is it necessary to put API.dll in the GAC if you have the Assembly Resolver? Perhaps if that dll were not in the GAC, Visual Studio wouldn't copy the other files over. I'm pretty sure it's that fact that a root DLL is in the GAC, but dependent DLLs are not.

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