How do I insert a string stored as a REG_SZ in the registry into a path? What I am trying to do is set .csproj references to a predefined path in our registry, but when I search all I am seeing is how the %PATH% env variable is stored in the registry. Here is an example of what I am trying to do:
<Reference Include="Inte开发者_JS百科rop.SienaASAP2, Version=1.3.0.0, Culture=neutral, PublicKeyToken=89a52a4f35bb97a3, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Bin\Interop.SienaASAP2.dll</HintPath>
</Reference>
Where the "..\..\..\" are, I would like to, for instance, insert the path at [HKEY_CURRENT_USER\Software\MyCompany\DefaultVersion\Folder]. Any help on this would be greatly appreciated.
Using out of the box behavior you can't have visual studio use HintPath by referencing a Environment variable.
This is how Visual Studio resovles the references form this MSDN Article
At build time, Visual Studio .NET resolves assembly references by searching the following locations in the following order:
Look for the assembly in one of the project folders. This assumes that you have added the assembly to the project by using the Add Existing Item menu option. Project folders include any folder displayed by Solution Explorer (except when Show All Files is in effect).
Look in the folders listed in the ReferencePath attribute of the element within the project user options file. This attribute can contain a comma delimited list of folders.
Use the
<HintPath>
element in the project file.Look in a set of folders identified by registry settings. These are the ones that contain assemblies displayed on the .NET tab of the Add references dialog box. For more details, see Using the .NET Tab of the Add Reference Dialog Box.
Look for COM Interop assemblies in the obj sub folder beneath the project folder. For more details, see Referencing COM Objects.
However that fourth option may help you just add your paths to one of these registry keys and then it will work without messing with HintPath
HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\AssemblyFolders
HKEY_CURRENT_USER\Software\Microsoft\.NETFramework\AssemblyFolders
精彩评论