How to enable the correct link in C # using the Browser tab

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

The .dll is not under the .NET, COM, or project tabs, so I only have a browser tab to add the .dll to the link.

My question is: how can I show VS to release the .dll version when compiling in release mode and take the debug version of the .dll when compiling in debug mode?

Thanks.

+2
visual-studio-2010
source share
5 answers

You probably need to manually edit the main .csproj file. Something like this

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

(It may be easy to add a link to the debug version through viewing, then right-click the project in the solution explorer, click "Unload project", then right-click again, "Edit your.csproj", make the above change to Foo.dll, which you just added, then right-click "Project Reloading".)

EDIT

To avoid looking at 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 

That is, conditionally set the Visible metadata under the node link to true / false based on the condition. I have not tried to find out if this works.

+3
source share

The best way to implement Brian's solution is to do it like this:

 <Reference Include="AjaxControlToolkit"> <SpecificVersion>False</SpecificVersion> <HintPath>path/to/folder/bin/$(Configuration)/AjaxControlToolkit.dll</HintPath> </Reference> 

It will be great to switch between Release and Debug if it doesn't appear twice in your Links view.

+11
source share

The standard approach is to add a project to the solution. Then it is fully automated.

+1
source share

we found the perfect way to handle this situation. first publish the library file in three special folders: $ (Configuration) \ MyLibrary.dll Debug \ MyLibrary.dll Release \ MyLibrary.dll

then in the application specify the link $ (Configuration) \ MyLibrary.dll '. made! Now you change the solution configuration, the dll will be automatically updated.

+1
source share

Starting from @Kevin Yang's answer, I did the following:

  • Build in path\to\Debug\MyCode.dll and path\to\Release\MyCode.dll .
  • Link to one of them in VS (using the "Overview" tab).
  • Unload the project that references your DLL.
  • Right-click on the downloaded project and click Edit MyReferencingProject.csproj...
  • Find the link and in the HintPath element change Debug / Release to $(Configuration) (so it should be path\to\$(Configuration)\MyCode.dll ).
  • Rinse / repeat (with any other similar DLLs).

When you are done, it should look like this:

 <Reference Include="MyCode"> <HintPath>C:\path\to\$(Configuration)\MyCode.dll</HintPath> </Reference> 
0
source share

All Articles