Visual Studio 2010: Insert Image in Code

Powered by WPF and MEF, the extensibility model in Visual Studio 2010 is richer than its previous versions.  You can easily extend the IDE, code editor, toolbars etc.

One such extension I stumbled upon recently is the Image Insertion extension that lets you insert images directly in line with your code to help you visualize aspects of your code. How cool! I recently used it to insert some UML diagrams within code. Although one may argue about the usefulness of this extension, it won’t harm to know that such an extension exists, in case you need one.

Download the Image Insertion Add-in from here.

Installing the Image Insertion extension

In case you have never installed an extension, here are multiple ways to do so:

1. VS 2010 introduces the Extension Manager (Tools > Extension Manager) that lets you install an extension. This tool lets you search the Visual Studio Gallery for an extension.

2. Alternatively, you can install an extension directly from Search for an extension and click the download button. If you choose to open, you will presented with a similar dialog box which installs the extension


3. You can use XCOPY to install an extension.

Note: Make sure you restart VS 2010 after installing an extension.

Once you have installed the Insert Image extension, just drag and drop an image on the code editor from either the Solution explorer or from Window Explorer. Here's an example of a UML diagram I dragged and dropped on the code editor.


To remove this image, place your mouse cursor over the image and a close button should appear. On saving the file, the image gets saved as a resource file.

About The Author

Suprotim Agarwal
Suprotim Agarwal, Developer Technologies MVP (Microsoft Most Valuable Professional) is the founder and contributor for DevCurry, DotNetCurry and SQLServerCurry. He is the Chief Editor of a Developer Magazine called DNC Magazine. He has also authored two Books - 51 Recipes using jQuery with ASP.NET Controls. and The Absolutely Awesome jQuery CookBook.

Follow him on twitter @suprotimagarwal.

No comments: