« Programmatically Generating HTML5 in C# without the Xml Declaration and using the correct html DTD - using XmlWriter, XmlDocument, and XDocument | Main | The Slick New Bariol Font Family by atipo »

Visio C# Automation Samples with NuGet  

Because I have been seeing the occasional requests for C# sample code (via sites like StackOverflow), this week I explored how we can use NuGet to make live much simpler. So I've published a new NuGet package called VisioCSharpSamples.


First, install NuGet: http://nuget.org/ 

Second, create an simple C# project in Visual Studio 2010 or Visual Studio 2012. The screenshots below show Visual Studio 2012 RC. In this case, let's pick a simple console application.

If you examine the Solution Explorer, you'll see the expected result.


Now select Tools > Library Package Manager > Package Manager Console


One the console loads, ensure that the Package source is pointing to the official NuGet feed



Then type in the following:

Install-Package VisioCSharpSamples

You'll see that the latest version of the samples is installed


Let's look at the Solution Explorer to confirm what happened.



Notice that a reference to Microsoft.Office.Interop.Visio was added.

Also, there is a folder called VisioCSharpSamples that contains several C# code files.

Currently, there's a static class called Samples that contains some static methods. The simplest is called HelloWorld found in the HelloWorld.cs file.


Of course, you can now simply call HellWorld() from your program and quickly get started transforming this hello world into something more complex.


  • NuGet makes it easy to get libraries into your projects in either source or binary form
  • I've published a NuGet package called VisioCSharpSamples that contains some useful source code snippets
  • Suggestions for additional samples are welcome





PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.
Author Email (optional):
Author URL (optional):
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>