in

CodePrairie .NET

South Dakota .NET User Group

I Hate Linux

WHS Developer Tip #6: Faster referencing

Q: Is there a faster way to add a reference to a Windows Home Server assembly instead of manually navigating to where the actual files reside?

A: The easiest way is to have the desired assemblies show up under the .NET tab of the Add References dialog:

Add Reference Dialog

Two things are required to achieve this, a local copy of the assemblies and a registry tweak.

Copying

If you haven't already, it's a good idea to just grab the entire C:\Program Files\Windows Home Server\ directory from your Home Server and copy it to your development machine for easier referencing and reflection.

Configuration

To add the necessary registry key:

1. Launch regedit

2. Navigate to the following registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx

3. Create a new key (folder) named 'Windows Home Server'
Note: You can name this key anything you want.

4. Change the default value to the path where the Windows Home Server assemblies exist on your development machine

When all done you should have something that looks like this (the actual path will depend on where you have the files located):

AssemblyFoldersEx\Windows Home Server key

For more info on displaying assemblies in the Add References dialog, see this MSDN article.

Configuration Alternative

A slightly quicker alternative is to download, modify (and use) this registry file to point to the directory on your development machine where the assemblies live.

Note: When you change the path to match the location on your machine, make sure that drives and directories are separated by two backslash characters instead of one as is normally seen in Windows (ie '\\' vs '\'). This is only required when modifying a registry file, not when using regedit.

Usage

Once the key has been added, re-launch Visual Studio, open or create a new project and launch the Add Reference dialog to be greeted with your new additions.

Benefits

Perhaps the greatest advantage of adding this key is that when you create a new project from a template that references a number different assemblies that you would ordinarily have to reference yourself (such as a Home Server Add-in) is that Visual Studio will automatically find the references assemblies for you based on this and other registry keys.

Drawback

One drawback of pointing the created registry key to a directory that contains all of the files from the server... is that all of the .NET assemblies show up in your Add References list. As nifty as it is to have ready access to the official files such as HomeServerExt.dll and Microsoft.HomeServer.SDK.Interop.v1.dll, we really don't need ready access to the Xceed libraries that you and are not licensed to use.

Applicability

Despite the fact that Visual Studio 2008 targets the new 3.5 Framework as well as the year old 3.0, this registry tweak still works as both 3.0 and 3.5 uses the 2.0 Common Language Runtime which this tweak targets, meaning it works just as well under 2008 as it does under 2005... as well as the Express edition and version of your choice.

Note: The information in this post is based on undocumented and at times deduced information on Windows Home Server and is not officially supported or endorsed by Microsoft and could very easily be wrong or subject to change in future, so please take it and everything else said on this blog with a grain of salt and use with caution.

Read the complete post at http://ihatelinux.blogspot.com/2007/11/whs-developer-tip-6-faster-referencing.html

Published Nov 19 2007, 10:50 AM by I Hate Linux
Filed under:
Powered by Community Server (Commercial Edition), by Telligent Systems