Click here to Skip to main content
Click here to Skip to main content

.NET Shell Extensions - Deploying SharpShell Servers

, 15 Sep 2013
Rate this:
Please Sign up or sign in to vote.
Learn how to deploy SharpShell servers easily with the new Server Registration Manager tool.

Introduction  

For the last few months, I've been working hard on the SharpShell project. This is a project that lets you quickly build Windows Shell Extensions using the .NET Framework. One difficulty that users were facing is that to deploy a Shell Extension written in .NET, you had to use the regasm tool, which would only be installed generally on development machines.

With SharpShell 2.0, there is a Server Registration Manager tool that makes deploying SharpShell servers a peice of cake.

The Series  

This article is part of the series '.NET Shell Extensions', which includes: 

  1. .NET Shell Extensions - Shell Context Menus  
  2. .NET Shell Extensions - Shell Icon Handlers  
  3. .NET Shell Extensions - Shell Info Tip Handlers     
  4. .NET Shell Extensions - Shell Drop Handlers   
  5. .NET Shell Extensions - Shell Preview Handlers   
  6. .NET Shell Extensions - Shell Icon Overlay Handlers
  7. .NET Shell Extensions - Shell Thumbnail Handlers
  8. .NET Shell Extensions - Shell Property Sheets    
  9. .NET Shell Extensions - Deploying SharpShell Servers 

What is SharpShell?  

SharpShell is a very lightweight class library that lets you build Windows Shell Extensions using the .NET Framework. As you can see from the links above, there are lot's of different types of servers that are supported. You can find a good intro on the GitHub page, as well as examples of each type of server:

https://github.com/dwmkerr/sharpshell  

Deploying Shell Extensions 

Deploying Shell Extensions written in C or C++ is generally straightforward, as the regsvr32 tool which is included in Windows can be used. However, to deploy a managed Shell Extension, the regasm tool must be used, which is not included by default on Windows. I have added the 'Server Registration Manager' tool (srm.exe) to SharpShell which makes it easy to install and uninstall servers. 

Installing Servers from the Command Line  

Download the SharpShell Tools binaries from this article, or get the latest from github.com/dwmkerr/sharpshell. Using this tool, you can install servers like this:

srm install server.dll -codebase 

Easy! You can uninstall the same server like this:

srm uninstall server.dll 

This is the key take-home from this article. The srm tool can install and uninstall servers - all other mechanisms (such as Windows Installers) will simply use this under the hood.

Creating an Installer for SharpShell Servers 

In this example, I'll use Visual Studio 2010 to create an installer for the 'Count Lines' extension that was written in the first article.

Tip: You can also use WiX - just create a custom action to run the commands shown above!

Step 1: Create the Installer Project

Create a new 'Setup and Deployment' project from Visual Studio 2010. Now add your SharpShell server and the srm.exe tool to the application folder, like so:

Step 2: Add Custom Actions to Install and Uninstall

Now navigate to the 'Custom Actions' section of the installer. Create a new 'Install' custom action that executes the srm.exe tool from the application folder: 

You can click on this action to set the properties. We'll need to pass the arguments 'install', the path to the server, and the '-codebase' flag (telling to install the server directly, not using a reference to the GAC).

Make sure that the 'InstallerClass' property is set to False, otherwise the installer will try and load an Installer Class object from the exe, which it doesn't contain.

Now create a similar action for Uninstall - this time we need the 'uninstall' command on the commandline, the server path as before, and no -codebase flag. This is the command line I use in this example:

uninstall "[TARGETDIR]\CountLinesExtension.dll" 

 That's it! You can now run your installer to install the SharpShell server!

Final Thoughts

This is a very short and sweet article, but many users who have been working with SharpShell have been requesting an easier way to deploy their servers, so here it is! 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Dave Kerr
Software Developer
United Kingdom United Kingdom
Follow my blog at www.dwmkerr.com and find out about my charity at www.childrenshomesnepal.org.
Follow on   Twitter

Comments and Discussions

 
GeneralThank you! PinmemberJulienV10-Mar-14 21:57 
GeneralRe: Thank you! PinmvpDave Kerr11-Mar-14 5:52 
Questionsrm.exe crashing when registering example DLLs [modified] PinmemberAlexanderPD8-Jan-14 0:51 
AnswerRe: srm.exe crashing when registering example DLLs PinmvpDave Kerr17-Jan-14 21:18 
QuestionProcess cannot access the file PinmemberMarla Sukesh25-Oct-13 18:42 
AnswerRe: Process cannot access the file PinmemberKugel Ball25-Nov-13 2:49 
GeneralRe: Process cannot access the file PinmvpDave Kerr25-Nov-13 8:34 
QuestionAdmin access PinmemberRudolfkingRegnor10-Oct-13 3:12 
AnswerRe: Admin access PinmvpDave Kerr12-Oct-13 5:51 
GeneralAnd again! PinprofessionalBrisingr Aerowing15-Sep-13 3:58 
GeneralRe: And again! PinmvpDave Kerr15-Sep-13 5:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140821.2 | Last Updated 15 Sep 2013
Article Copyright 2013 by Dave Kerr
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid