如何使用“浏览器"在 C# 中包含正确的引用标签 [英] How to include the right reference in C# using the "Browser" tab

查看:33
本文介绍了如何使用“浏览器"在 C# 中包含正确的引用标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 VS2010 C#,我想添加一个在 VS2008 下编译的 .dll 引用;此 .dll 存在 2 个版本:调试和发布.

I am working on VS2010 C# and I want to add a .dll reference compiled under VS2008; this .dll exists in 2 versions: Debug and Release.

.dll 不在 .NET、COM 或项目选项卡下,所以我只有浏览器"选项卡将 .dll 添加到引用中.

The .dll is not under .NET, COM or projects tabs, so I only have the "browser" tab to add the .dll to the reference.

我的问题是:如何向 VS 指示在发布模式下编译时采用发布 .dll 版本,并在调试模式下进行编译时采用调试 .dll 版本?

My question is: How can I indicate to VS to take the release .dll version when I compile in the release mode and to take the debug .dll version when I compile in the debug mode?

谢谢.

推荐答案

您可能需要手动编辑基础 .csproj 文件.大约这样

You'll probably need to manually edit the underlying .csproj file. Approximately thusly

<Reference Condition=" '$Configuration'=='Debug' " 
           Include="path\to\Debug\Foo.dll" />
<Reference Condition=" '$Configuration'=='Release' " 
           Include="path\to\Release\Foo.dll" />

(通过浏览添加对调试版本的引用可能很容易,然后在解决方案资源管理器中右键单击项目,单击卸载项目",然后再次右键单击,编辑您的.csproj",将上面建议的编辑添加到您刚刚添加的 Foo.dll,然后右键单击,重新加载项目".)

(May be easy to add a reference to debug version via browse, then right click project in solution explorer, click 'Unload project', then right click again, 'Edit your.csproj', make the edit suggested above to the Foo.dll that you just added, then right click, 'Reload project'.)

编辑

为了防止在 VS 中看到两个副本,可能类似于

To prevent seeing two copies inside VS, maybe something like

<Reference debugstuff as before>
    <Visible Condition=debugcond>true</Visible>
    <Visible Condition=releasecond>false</Visible>
</Reference>
and same for release

即根据条件有条件地将引用节点下的Visible元数据设置为true/false.我还没有尝试知道它是否有效.

That is, conditionally set Visible metadata under the reference node to true/false based on the condition. I haven't tried to to know if it works.

这篇关于如何使用“浏览器"在 C# 中包含正确的引用标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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