in

CodePrairie .NET

South Dakota .NET User Group

I Hate Linux

November 2007 - Posts

  • WHS Developer Tip #5: Images and Icons

    Q: How can I use some of the pictures and icons that are used by the Home Server Console?

    A: Rather than violating the EULA and ripping the images you want straight from the files that came with Windows Home Server (which is certainly possible)... you can look to the CommonImages class (Microsoft.HomeServer.Common.Client, WHSCommon.dll) and it's 71 public static properties (69 of which return something), each of which returns different icon or image that can help you better theme your add-in.

    Here are some of the available images:

    ImagesAndIcons

    One unfortunate limitation of CommonImages is that some of the more sought after icons like those used for add, delete, edit and properties are not present... however a green check and red x are.

    You could randomly guess which is which... or you can use one of these two applications (C# or VB) which displays them.

    CommonImages Example Application

    With any luck, eventually Microsoft will make available (either officially or unofficially) more of the art used in the Home Server Console so that developers can better integrate visually with it.

    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.

  • Edge cases and polishing

    Some say that that the majority of developers are psychologically incapable of adequately testing their own code (outside of unit testing) because subconsciously they know where their program works and where it doesn't and will avoid straying from the path so that their program keeps working great.

    I admit it... I'm one of those developers.

    Right now I'm having the fun of forcing myself down random paths to test strange edge cases for my new Windows Home Server add-in... cases that it would be more than fair for me to just say say "Sorry, but you did something I told you not to do and now this add-in cannot clean up after itself"... but I'm not.

    Technically everything I am doing is unsupported by Microsoft as I'm using a number of Windows subsystems that shouldn't ordinarily be used by a Windows Home Server user... in fact normal use of them could even violate the end user license agreement.

    What I'm trying to do this evening is do my best to make sure that even if a user enables DFS and dinks around with that or other such systems, I'm able to gracefully handle dang near anything the user might have done.

    That being said... grrr.

    Once I've got those edge cases accounted for... I need to improve my logging and I'll be all set.

    </rant>

  • WHS Developer Tip #4: Project Templates

    Q: Is there an easier way to get started in building my add-in other than building it from scratch... like a project template?

    A: There are no official project templates and to fill this gap back in April (now) WHS MVP Ken Warren did release a couple example templates that I've used for every single add-in and test add-in I've written.

    Unfortunately as useful as his templates are, they have a number of issues that require some extra work to make work property, so I built a couple of new and improved ones:

    Looking for another language? Managed C++? J#? Feel free to ask.

    Installation Instructions

    Copy to language template of your choice to the following directory on your Vista development machine:

    %UserProfile%\Documents\Visual Studio 2005\Templates\ProjectTemplates\<Language>\

    or under XP/2003:

    %UserProfile%\My Documents\Visual Studio 2005\Templates\ProjectTemplates\<Language>\

    Where <Language> is either Visual C# or Visual Basic.

    Usage

    Launch Visual Studio 2005**, bring up the New Project dialog and select the language of your choice. Under the My Templates section you will see a template named Home Server Add-In (apologies for the poor icons*), select it, type in a name for your project and press the OK button.

    The created project will contain 2 different kinds of files, user controls and the required Home Server classes.

    Two classes named HomeServerTabExtender and HomeServerSettingsExtender do the work of informing the Home Server Console what controls exist in your add-in, what their display name should be and other settings. With the exception of changing the display text and icon, you can largely leave these classes alone.

    There are also two user controls named MainTabUserControl and SettingsTabUserControl which are the place for you to add your custom layout and code with the ease of the Visual Studio Forms Designer.

    There are just two things that you'll need to do before your new add-in will be useable on your Home Server...

    Add Reference

    Unless you've specially rigged your development environment (which I'll cover in a later Dev Tip), you'll need to manually add a reference to HomeServerExt.dll (located in C:\Program Files\Windows Home Server\ on your Home Server).

    Visual Studio Bug

    For your add-in to be detected by the Home Server Console, the deployed assembly must have a name and namespace that match the following pattern:

    Assembly Name:
    HomeServerConsoleTab.YourTabName

    Namespace:
    Microsoft.HomeServer.HomeServerConsoleTab.YourTabName

    Where YourTabName is the unique name you've given to your tab.

    In order to make your tab meet these requirements, you will need to edit your project's properties and change the assembly name to meet the above criteria.

    As easy as it is to make an add-in with these templates, a bug exists in Visual Studio 2005 and 2008 which allows the dynamic naming of the namespace based on the project name you specify... however the assembly name is always set to the project name, something that isn't always desired.

    Deployment

    To use your new add-in, simply copy it to the C:\Program Files\Windows Home Server\ directory on your Home Server and re-start the Home Server Console.

    You can also make your own installer using WiX or Visual Studio Setup Project to install your add-in through the Home Server Console.

    *If any readers have any suggestions as to how these templates could be improved, or want to make a better looking icon for the templates, please let me know.

    **These templates have also been tested with the the beta 2 version of Visual Studio 2008 and to make them visible, change the directories mentioned previously appropriately (2005 -> 2008).

    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.

  • 24: The Unaired 1994 Pilot

    Jack Bauer saves the world with AOL 3.0.

    If you'll excuse me... I need to go dry my eyes.

  • Q Home Server Install Doc

    I was browsing around some of the nooks and crannies of my Home Server this evening and ran into a file named readme.txt (located in C:\Inetpub\remote\readme.txt) which said:

    Q Home Server Install Doc

     

    To install remote access for Q Home Server follow these steps.

    1. Run RemoteAccess.msi
    This will install the website

    3. Run dsa.msc and create a user
    If you want a user to have remote access, add them to the "Remote Desktop Users" group

     

    4. Configure your router
    Setup your router to forward ports 80 and 4125 to the Q Server.

     

    5. Using a web browser, navigate to your external ip address and use Microsoft Home Server Remote Access
    https://myServerName/Remote

    While it's clear that this file pre-dates the initial beta of Windows Home Server and probably should have been removed sometime between then and now, one has to wonder just how old it's instructions may be and for how long they were relevant (ie using dsa.msc to create a user).

    While the presence of this file isn't by itself important, it does go a long way to remind us though just how far WHS has come and how polished it has become, that now even for setup a user never has to touch the actual home server desktop.

  • Survey says... It needs your input

    As part of his eternal studenthood (with the current phase occurring at UNL), Dan over at tdaxp has put out a call for participants for a 30 minute survey that focuses on Creativity and Blogging.

    Do you have 30 minutes you don't mind burning for the cause of science? No? Come on, it's easy and it helps out with something that is described as:

    This is a research project to study the correlation between cognitive, affective, and behavioral attitudes on creativity in the domain of blogging.  (“Blogging” refers to maintaining an informal, chronologically sorted online journal.) 

    Then stop on by and take the survey.

  • Grumble Grumble Visual Studio bugs

    Off and on for the last couple of days I've been playing around with making Visual Studio project templates and customizing them with Template Parameters and ran into a little issue... the assembly name template being specified in the larger template is simply ignored.

    What does that mean? If I create a custom template with the AssemblyName tag being specified as say... Xyz.$safeprojectname$, and create a project named "My Test Project" based on it... the resulting assembly name is "My Test Project", not Xyz.My_Test_Project as that syntax would generate for a namespace... even on a fully patched copy of Visual Studio 2005.

    From the looks of it this has been bugged before on Connect... but ultimately closed as not reproducible.

    Thinking I can show how to reproduce it.. I've submitted it myself: Custom AssemblyName tag ignored in template.

    There still exists a problem... the same issue exists in at least Beta 2 of Visual Studio 2008. Someone first pointed it out in April 07 as existing in the March CTP, and in my testing it seems that this still exists... so it to has been bugged.

    Grrr.

    Double Grrr I suppose when it sounds like Beta 2 will be the last publicly available version of Visual Studio 2008 before they RTM so there will be no way for me to know if this bug has/will be fixed by then.

  • WHS Developer Tip #3: Intellisense

    Q: How can I make Visual Studio provide more useful Intellisense support for the Windows Home Server SDK?

    A: In order to get Intellisense support in Visual Studio a developer needs an xml file that contains all of the xml comments from the original code, something that was likely used to create the documentation available on MSDN today... unfortunately no such xml files have been made available for Windows Home Server from Microsoft, instead developers are forced to go without or make them themselves.

    Based on the documentation on MSDN, I have created a pair of xml documentation files for both HomeServerExt.dll and Microsoft.HomeServer.SDK.Interop.v1.dll which are available for download here.

    In order to use these them, you will need to extract the two xml files to the same directory where HomeServerExt.dll and Microsoft.HomeServer.SDK.Interop.v1.dll live on the machine you are developing on:

    DocumentationNextToSDKAssemblies

    Once extracted, you need only add a reference to one (or both) of these assemblies (that sits next to the associated xml file) in Visual Studio and the documentation will be there for you.

    Note that if you want to use this documentation in an existing project, you will first need to delete the references and then re-add them.

    Regardless of if you are writing your add-in in C# or VB.NET, once copied and (re)referenced, you'll turn this kind of view:

    IShareInfo with out description

    into this one:

    IShareInfo with description

    Note: These files have been tested in Visual Studio 2005 and 2008 Beta 2 in both VB and C#.

    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.

  • Windows Home Server: Client-Side SDK

    As reported elsewhere (MS Windows Home Server and Windows Home Server Blog), there is a new video on Channel 9 (as well as one on on10.net with Charlie Kindel) that is a sit down with Home Server Lead Developer Chris Gray (get back to the blogging man!) where he talks about building add-ins for Windows Home Server.

    What hasn't been reported anywhere else is that Chris also mentioned a client-side SDK for Home Server and when I asked about it Home Server General Manager Charlie Kindel chimed in and said in part:

    Chris sorta "mis-spoke" and "let the cat out of the bag" when he talked about the client-side SDK stuff.

     

    We are working on it.

     

    We have not announced when it will be released in pre-release form.

     

    We have not announced when it will be released in the product.

    Great to hear it's being worked on and so long as it gives the same kind of access to WHS as the functionality in Microsoft.HomeServer.SDK.Interop.v1 does on the server I'll be thrilled.

    If they give us a way to first put client-side code on the server and then deploy it to clients automatically... I'll be ecstatic.

    Granted the first bit is more likely in a V1 product than the second... a dev still has to hope.

  • Belated Congrats

    Major (and a month late) congratulations goes to Andrew Grant (no relation) and his add-in Whiist, David Wright and his Jungle Disk and Prakash Gautam with Community Feeds for Windows Home Server for winning the Microsoft Windows Home Server Code2Fame Challenge.

    It's truly wonderful to see so many great add-ins being created for this new platform and look forward to seeing in the coming months what ideas couldn't make it in to the competition.

    On the plus side it looks like my entry did receive an honorable mention (scroll to the bottom).

  • WHS Developer Tip #2: MessageBox alternative

    Q: How can I make a more WHS style Message Box like what the Home Server Console uses?

    Example:
    Example QMessageBox

    A: The Windows Home Server team already beat you to it and created the QMessageBox class (Microsoft.HomeServer.Controls, HomeServerControls.dll) which provides a very similar experience to the tried and true MessageBox class... only with a few improvements such as...

    Size and Color

    One of the first things a programmer testing out QMessageBox will notice is that the dialog is far larger than a regular MessageBox and is formatted to look more WHS like in terms of icons and color and is probably the biggest reason to consider using it (over making ones own dialog from scratch).

    Icons

    Keeping the future in mind, the developer(s) behind QMessageBox actually changes its appearance in another key way by replacing the default system icons (as based on the MessageBoxIcon enumeration) with those that ship today with Windows Vista instead of the ones that would ordinarily be displayed by Windows Server 2003.

    For comparison, the following image (click for larger) shows the difference between MessageBox and QMessageBox being used on Windows XP, 2003, Vista and Home Server:

    MessageBox vs QMessageBox

    (Note: The above Windows 2003 MessageBox examples were run on a Windows Home Server machine.)

    An unfortunate limitation of QMessageBox is that internally something is wrong with it's handling of the MessageBoxIcon.Question value because use of it will raise an ArgumentException, so be sure to stick with one of the other 4 working values (None, Asterisk, Hand, Question & Warning).

    If all of this wasn't enough, one of the biggest (and least obvious) features of QMessageBox is that it allows you to specify an arbitrary image in place (in some overloads) of a MessageBoxIcon:

    QMessageBox with CustomImage

    Multi-line

    A major pet peeve of mine about MessageBox was that it only had two text areas that you could use, the text argument displayed in the body of the window while the caption argument was displayed in the title bar. For any more advanced formatting you had to make your own dialog or add new line characters to separate certain areas... QMessageBox takes this idea and extends it by allowing a third argument named title which appears as a bold area of text that appears above where the text is.

    Dual Line QMessageBox

    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.

More Posts « Previous page
Powered by Community Server (Commercial Edition), by Telligent Systems