Setting Up an Add-In Solution
This Programming Tutorial shows you how to create a sample Windows Home Server add-in by using a Visual Studio solution.
This section walks through setting up both the Visual Studio solution and the Visual Studio project for the Console and Settings tabs.
Setting up Your Add-In Solution
When you create a new project in Visual Studio, you can create a Visual Studio solution at the same time to hold your project. Because you are creating an add-in that adds a tab to the Windows Home Server Console, you must create a .dll file. You create .dll files in Visual Studio by using a Windows Class Library project.
Creating the Class Library Project
In the following procedure, you create a Visual Studio class-library project and a Visual Studio Solution that contains the project.
To create a class library project in Visual Studio
With Visual Studio open, click File, point to New, and then click Project.
In New Project, in Project Types, expand the node for the programming language that you want to use to create your application, in this instance Visual C# or Visual Basic.
In Templates, click Class Library.
If you are using Visual Studio 2008, select .NET Framework 2.0 as your target Framework from the drop down list.
For the purposes of this walkthrough, name your project SDKSample.
Note that Solution Name is the same as the project name by default. The solution name can be different from the project name, but for the purpose of this tutorial, accept the default solution name, SDKSample.
Make sure that Create directory for solution is selected.
Confirm Name, Location, and Solution Name, and then click OK to close New Project and to create your new class-library project. A new Visual Studio solution is also created at the same time, and it contains your new class library project.
Setting the Properties of the Class Library Project
The Windows Home Server API requires that your .dll follow a specific naming convention. If you do not name your .dll as explained in the following section, your tab will not be loaded by the Windows Home Server Console.
Following Windows Home Server naming conventions for a .dll that extends the Windows Home Server Console
To ensure that the Windows Home Server Console recognizes and loads your tab, you must name your .dll file HomeServerConsoleTab.YourTabName.dll. You cannot change the first part of the file name, HomeServerConsoleTab. The second part of the .dll file name, YourTabName, can be any name that you choose and should not be a name that is used by any other tabs. In this way, your tab is distinguished from other tabs. For example, the Shared Folders tab in the Windows Home Server Console is implemented in the .dll file HomeServerConsoleTab.Sharing.dll.
Important
Classes that create tabs for Windows Home Server without Power Pack 1 must be contained in the Microsoft.HomeServer.HomeServerConsoleTab namespace, must be named HomeServerTabExtender, and must implement the IConsoleTab interface. Only the first instance of this new tab that the Windows Home Server server software encounters will be loaded into the Windows Home Server Console. Classes that create tabs for Windows Home Server with Power Pack 1 can be contained in any namespace and have any name, but also must implement the IConsoleTab interface.
To set the name of the .dll for the class-library project
In Visual Studio, right-click SDKSample in Solution Explorer, and then click Properties.
On the tab for SDKSample properties, click Application.
In Assembly Name, type HomeServerConsoleTab.SDKSample. Later, when you build your .dll, it will have the correct naming convention of HomeServerConsoleTab.YourTabName.dll. In this tutorial, Visual Studio outputs the SDKSample project to a .dll named HomeServerConsoleTab.SDKSample.dll.
On the main menu, click File, and then click Save All.
Keep the properties tab open for the next procedure.
Adding Project Resources
The only project resource that you need for your class-library project is a bitmap image. The bitmap appears on your Console tab as well as on your Settings tab.
Important
The bitmap must be 32 x 32 pixels. A bitmap with any other dimensions does not display correctly.
This tutorial uses an image file, SDKSample.png, but you can use any appropriate bitmap for your project. Add the bitmap image as follows.
To add the bitmap image to the resources for the class-library project
On the tab for SDKSample properties, click Resources.
If it appears, click the message This project does not contain a default resources file. Click here to create one.
Click the down arrow that is next to Add Resource, and then click Add Existing File.
Browse to the location of your bitmap image. Click the image file, and then click Open. A thumbnail of your image is added to the list of images resources for your project, with the name of the image file (without a file extension).
Note
You can change the name of the image file by renaming it in the Resources display pane. For example, rename SDKSample to SDKSampleImg to more easily recall what this resource is when it is referenced in code.
On the main menu, click File, and then click Save All.
Close the SDKSample properties tab.
Adding references to your class-library project
In order for your project to build correctly, make sure that you add the appropriate references. When you extend the Windows Home Server Console, you must reference the Microsoft.HomeServer.Extensibility
namespace. The Microsoft.HomeServer.Extensibility
namespace contains the API code that you use to create a new Console tab or Settings tab. The Microsoft.HomeServer.Extensibility
namespace is contained in HomeServerExt.dll.
Because this tutorial demonstrates how to work with Windows Home Server objects besides Console tabs and Settings tabs, you also need to reference the Microsoft.HomeServer.SDK.Interop.v1
namespace, where all other Windows Home Server objects are defined. The Microsoft.HomeServer.SDK.Interop.v1
namespace is contained in Microsoft.HomeServer.SDK.Interop.v1.dll.
To add the appropriate references for the project, copy HomeServerExt.dll and Microsoft.HomeServer.SDK.Interop.v1.dll to your development computer, and then add a reference to them in your project's references.
To add references to HomeServerExt.dll and Microsoft.HomeServer.SDK.Interop.v1.dll
Copy HomeServerExt.dll and Microsoft.HomeServer.SDK.Interop.v1.dll from the %ProgramFiles%\Windows Home Server\ directory on the home server to a folder on your development computer, for example, "C:\HomeServerSDK."
In the Visual Studio Solution Explorer view, expand the SDKSample project.
If you are using C#, right-click References, and then click Add Reference. If you are using VB, right-click SDKSample, then click Add Reference.
On the Add Reference dialog, click the Browse tab, and then navigate to the location where you copied HomeServerExt.dll and Microsoft.HomeServer.SDK.Interop.v1.dll.
Select both files by holding down CTRL and clicking each file. Click OK to close Add Reference.
Repeat steps 1 through 3 for the System.Drawing and System.Windows.Forms namespaces, with the exception that these references are on the .NET tab.
HomeServerExt, Microsoft.HomeServer.SDK.Interop.v1, System.Drawing, and System.Windows.Forms appear in References in Solution Explorer(C#), or in References in the SDKSample properties tab (VB). Additionally, in the Visual Studio Object Browser window, the HomeServerExt and Microsoft.HomeServer.SDK.Interop.v1 nodes appear.
For the purposes of this walkthrough, rename the code file for your class to HomeServerTabExtender.cs (C#), or HomeServerTabExtender.vb (VB). To do so, right-click Class1.cs (C#), or Class1.vb (VB), in Solution Explorer. Click Rename on the popup menu. Rename the file to HomeServerTabExtender.cs (C#), or HomeServerTabExtender.vb (VB).
If a message appears asking if you want to rename all references to this class in your project, click Yes.
On the main menu, click File, and then click Save All.
Summary
The Visual Studio solution is set up and the properties for your class library project are configured. You are now ready to create the user interface and write the code for your Add-in using the Creating a Console Tab section of this tutorial.
See Also
Concepts
Creating a Settings Tab
Deploying an Add-In
Extending Windows Home Server