12

This might be a silly question but I have to add reference to %programfiles(x86)% folder (on a 64 bit machine) OR to %programfiles% folder (on a 32 bit machine). I also have to set CopyLocal to false so that the DLLs are not copied to bin/debug folder of my project but always point to the same %programfiles% location.

How do I add reference to %programfiles(x86)%in Visual Studio 2010?

Mayank
  • 1,621
  • 2
  • 14
  • 30

3 Answers3

12

The solution is to edit the .csproj manually by opening it in a text editor and changing the HintPath of the DLL that you are referencing. Since I always need to refer location of 32-bit Program Files, I use $(ProgramFiles) in HintPath which resolves to %programfiles% or %programfiles(x86)% automatically.

Mayank
  • 1,621
  • 2
  • 14
  • 30
8

An alternative to "$(ProgramFiles)" is "$(MSBuildProgramFiles32)", which may be slightly more future-proof. See here: Use 32bit "Program Files" directory in msbuild

Community
  • 1
  • 1
RenniePet
  • 11,420
  • 7
  • 80
  • 106
0

Adding reference to dll in program files looks a bit weird to me. Is this your company's dll or some 3rd party? If it's yours maybe you should reconsider putting it in GAC.

Piotr Perak
  • 10,718
  • 9
  • 49
  • 86
  • 1
    @Perl Its a third party dll which gets installed in `%programfiles(x86)%\SomeFolder`. I need to refer them from there and not create additional copies of their DLLs in our installer. – Mayank Aug 11 '11 at 10:10