Click here to Skip to main content
13,865,831 members
Click here to Skip to main content
Add your own
alternative version


41 bookmarked
Posted 30 Mar 2005

Building a Shared Code Library as a VS.NET Plug-in

, 30 Mar 2005
Rate this:
Please Sign up or sign in to vote.
A plug-in for VS.NET that stores code snippets in a database. From the plug-in you can add code, search the database for code snippets. Also includes examples on how to integrate with the IDE as a plug-in.


The "CodeManager" is a plug-in for VS.NET that stores code snippets in a database. From the plug-in you can add code, search the database for code snippets to insert into your code. That is really the core of it. The reason why I took all the effort of creating this, was that we (the developer collective) needed a way to share code in our organization. Hence, one very misspent vacation, writing this! In an attempt to justify the time spent on it, I am now inflicting it upon you.

Having done some analysis on what was out there (looking to buy a third party solution - turns out they were overpriced), I thought I could get similar results in just a few days, at a fraction of the cost. I built this during a short vacation over an year ago, hence the code quality is not something I would be proud of, but it does the job it was designed to. To me its a good example of re-use, and leveraging code/classes that already exists, and was able to reduce the development time by orders of magnitude.

This would be interesting to you if;

  • You want to learn how to create a real world VS.NET plug-in.
  • You need a shared code library that you can maintain and extend internally.

Here are a couple of screenshots of it in action:

Adding code to the library

Searching for code


This book gave me some crucial tips in order to get this done quickly: Writing Add-ins for Visual Studio .NET.

I have used and extended the code from Julijan's add-in to include a versioning controlled build in the project, as detailed in the article Versioning Controlled Build.

Using the code

You can either use the installation and DB script to set up a working installation, or set up the code in your IDE. I recommend the latter, though it requires more effort it gives you the opportunity to really examine what is going on.

The overall concept is the same for using ToolWindows in .NET. The VSUserControlHost DLL needs registering (if you don't go through the installer). This is then used to host a usercontrol, which contains all the functionality for the ToolWindow (as seen in the main screenshot). This user control presents an interface to SQL Server database which contains code snippets. Other integration points are the main menu entries, the toolbar entries, an Options dialog and the output windows (all are displayed below in images). Users are validated using Windows Authentication/Active Directory and added dynamically. I have also included an updated version of the version updater (sorry about that sentence), as listed in the references by Julijan Sribar.

The Context Menu

The Main Menu

The Output window

Toolbar items

Setting up

  • You need a SQL DB server to use. Create a database, call it RADDev, and install the supplied script there.
  • You also need to register VSUserControlHostLIb - the project is provided with the code. Open a command prompt, navigate to the folder where the VSUserControlHost.dll is, and type in regsvr32 VSUserControlHost.dll.
  • Now, open the solution, and you will see three projects.
  • WinUserControlTestProject - this is the project used to test the functionality in the main user control during development. It is convenient while testing add-ins to have a separate test application to test the core functionality, as reloading the add-in becomes a drain on debugging time.
  • RadDevSetup - this is the setup program, which builds the redistributable. Nothing remarkable about this.
  • Lastly, RadDev - this is the add-in project itself, which does have lots of interesting things about it.

Points of interest

  • clsCodeDBFunctions – this interfaces with the data accessor class below clsDBTier – this is an accessor block type class. It is quite out of date now, but it still does the job.
  • clsNodeTag: This stores the information for a tree node, it is just a holder class (should probably be a struct, but who knows what more needs to be added in the future).
  • clsRegistration – handles registration of licenses, new users, and decrypts licenses for checking. The registration isn't being checked anymore in the current code set. The build I made for the company was limited to the company's domain.
  • clsWinAuthentication – this class authenticates the user against their Windows domain and user, then checks against the database to see if they have been already added. If they are a new user, they are prompted to enter more details, and subsequently added to the database. It is important to know who is adding articles, as only the user who has added can delete it. Also I have written controls in ASP.NET applications that create content based on the contents of the database, so you need names for the articles.
  • Crypto.vb – this is used for encryption/decryption of license keys. All credit for this goes to Stan Schultes.
  • I am not going into greater details of the code as it is a lot interesting, but nothing in particular stands out to me. You really need to pick out the things that interest you the most from the code set itself.


It really needs a thorough cleaning up in terms of removing unused code. What it needs the most is someone who really needs this tool, to take ownership of it (I have too many other projects/commitments), and do a cleaning and rinsing on it. Hence I am freeing it to the world. There are lots and lots of areas where it can be improved. There are some redundant classes, like VSS integration and maintain database versioning, which are still good ideas, but could not make it into this version. My plan was to create a tool that also did integrated change management, linking to a web based system that I was already using. I think there is a call for an open source plug-in that covers these areas. I believe the market prices of the commercial options are over-priced.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

paul heap
Web Developer
Thailand Thailand
Spent my whole life developing, having worked in C++, Delphi, ASP, then finally settling down to working solely in ASP.Net. Also a forex day trader.

You may also be interested in...


Comments and Discussions

Questionabout you! Pin
ConHulio12-Jun-13 9:48
memberConHulio12-Jun-13 9:48 
Generalplease move to a new database :) Pin
Member 21894927-Jul-05 16:31
memberMember 21894927-Jul-05 16:31 
GeneralTry to get it to work Pin
Member 153733614-Apr-05 11:21
memberMember 153733614-Apr-05 11:21 
GeneralRe: Try to get it to work Pin
kScope14-Apr-05 22:56
memberkScope14-Apr-05 22:56 
Generalnot able to set database settings in Raddev option Pin
ashu_sharma2112-Apr-05 1:07
memberashu_sharma2112-Apr-05 1:07 
QuestionHow to get it working Pin
Steve Hurcombe8-Apr-05 2:00
memberSteve Hurcombe8-Apr-05 2:00 
AnswerRe: How to get it working Pin
paul heap12-Apr-05 6:32
memberpaul heap12-Apr-05 6:32 
GeneralWrite DRY Code Pin
Tad McClellan4-Apr-05 8:23
professionalTad McClellan4-Apr-05 8:23 
GeneralRe: Write DRY Code Pin
paul heap4-Apr-05 18:29
memberpaul heap4-Apr-05 18:29 
GeneralRe: Write DRY Code Pin
Dot Netter5-Apr-05 14:44
memberDot Netter5-Apr-05 14:44 
GeneralDoesn't work :-( Pin
Niteman4-Apr-05 0:18
memberNiteman4-Apr-05 0:18 
GeneralRe: Doesn't work :-( Pin
Anonymous4-Apr-05 0:41
memberAnonymous4-Apr-05 0:41 
GeneralWiki Pin
Marc Clifton1-Apr-05 1:53
protectorMarc Clifton1-Apr-05 1:53 
GeneralRe: Wiki Pin
paul heap1-Apr-05 18:18
memberpaul heap1-Apr-05 18:18 
Generaldatabase user Pin
Member 31208131-Mar-05 9:15
memberMember 31208131-Mar-05 9:15 
GeneralRe: database user Pin
paul heap31-Mar-05 18:35
memberpaul heap31-Mar-05 18:35 
GeneralRe: database user Pin
Levi Rosol1-Apr-05 6:56
memberLevi Rosol1-Apr-05 6:56 
GeneralRe: database user Pin
paul heap1-Apr-05 18:37
memberpaul heap1-Apr-05 18:37 
GeneralRe: database user Pin
kScope6-Apr-05 6:58
memberkScope6-Apr-05 6:58 
GeneralRe: database user Pin
paul heap6-Apr-05 20:01
memberpaul heap6-Apr-05 20:01 
GeneralRe: database user Pin
kScope8-Apr-05 7:02
memberkScope8-Apr-05 7:02 
GeneralNo Code Pin
jhidey31-Mar-05 2:58
memberjhidey31-Mar-05 2:58 
GeneralRe: No Code Pin
paul heap31-Mar-05 4:33
memberpaul heap31-Mar-05 4:33 
GeneralRe: No Code Pin
paul heap31-Mar-05 4:43
memberpaul heap31-Mar-05 4:43 
GeneralUpdates to download Pin
paul heap30-Mar-05 21:53
memberpaul heap30-Mar-05 21:53 

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

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

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web03 | 2.8.190214.1 | Last Updated 31 Mar 2005
Article Copyright 2005 by paul heap
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid