Content by Category
.NET 1.x
.NET 2.0
.NET 3.0
.NET 3.5
.NET 4.0
.NET 4.5
.NET Assemblies
.NET Framework
.NET Getting Started
Accessibility
ADO.NET
Advertorials
Agile Development
AJAX
Amazon Web Services
Analysis Services
Android
Architecture
Arduino
ASP .NET Web API
ASP.NET
ASP.NET MVC
ASP.NET WebForms
Azure
B2B (Business Integration)
BDD
Big Data
Bing
BizTalk
Book Excerpts
Build and Deploy
Business Intelligence
C#
C++
ClickOnce
Cloud Computing
Code Contracts
CODE Framework Info - non Technical
CODE on the Road!
COM+
Community
Conferences
Continuous Integration
Crystal Reports
CSLA.NET
CSS
Data
Debugger
Design Patterns
Development Process
Display Technologies
Distributed Computing
Document Database
DotNetNuke
DSL
Dynamic Languages
Dynamic Programming
Editorials
Enterprise Services ("COM+")
Entity Framework
Events
Expression Blend
F#
Fox to Fox
Frameworks
Functional Programming
Git
Graphics
HTML 5
Internet Explorer 8.0
Interviews
IOS
iPhone
Iron Ruby
Java
Java Script
JavaScript
jQuery
JSON
Lightswitch
LINQ
Linux
LUA
Mac OS X
MDX
Messaging
Metro
Microsoft Application Blocks
Microsoft Business Rules Framework
Microsoft Dynamics
Microsoft Expression
Microsoft Office
Mobile Development
Mobile PC
Mono
MsBuild
MVVM
MySQL
Network
NHibernate
node.js
NOSQL
Nuget
Object Oriented Development
Objective C
Odata
OLAP
Open Source
Opinion
Opinions
Oracle
ORM
Other Languages
Parallel Programming
Patterns
PHP
Podcasts
Post Mortem
PowerPoint
Print/Output
Prism
Product News
Product Reviews
Project Management
Prolog
Python
Q&A
Rails
Rake
Razor
Reporting Services
REST
RIA Services
Ruby
Ruby on Rails
Scheme
Search
Security
Services
SharePoint
SignalR
Silverlight
SOA
Social Networks
Software & Law
Software Business
Source Control
Speech-Enabled Applications
SQL Server
SQL Server 2000
SQL Server 2005
SQL Server 2008
SQL Server 2012
SQL Server CE/AnyWhere/Mobile/Compact
SSIS
Subversion
Sync Framework
Tablet PC
TDD
Team System
Techniques
Testing and Quality Control
TFS
Tips
TypeScript
UI Design
UML
User Groups
VB Script
VB.NET
Version Control
VFP and .NET
VFP and SQL Server
Virtual Earth
Vista
Visual Basic
Visual Basic 6 (and older)
Visual FoxPro
Visual Studio .NET
Visual Studio 11
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Visual Studio 2011
Visual Studio 2012
Visual Studio Tools for Office
VSX
WCF
Web Development (general)
Web Services
WebMatrix
WF
Whitepapers
Windows 7
Windows 8
Windows Azure
Windows Live
Windows Phone 7
Windows Phone SDK
Windows Server
Windows Vista
WinForms
WinRT
Workflow
WPF
XAML
Xiine Documentation
XML
XNA
XSLT



LearnNow


XAMALOT
 


CODE Training

Reader rating:
Click here to read 14 comments about this article.
Article source: CoDe (2008 - Vol. 5 - Issue 1 - Extensibility)


Article Pages:  1  2 3 - Next >


Creating Visual Studio Add-Ins

Visual Studio provides one of the most powerful IDEs on the market. One under-exploited aspect of this IDE is the extensibility model. Programming IDE’s are not static development tools. Development techniques, tools, and concepts change. Extensibility has been built into Visual Studio from its early inceptions. The great thing about Microsoft’s foresight is that you can augment functionality of Visual Studio yourself. This article will demonstrate how to extend the Visual Studio IDE using Visual Studio, the .NET Framework, and the Visual Studio add-in and automation models.

The Visual Studio IDE has a number of built in extensibility models.

  • Macros/automation model
  • Add-Ins
  • Templates
  • Packages

This article will mash the first three together to create a robust solution creation platform. You will learn how to create a basic add-in, how to extend that add-in using the automation model, and finally how to combine solution templates into the mix to make yourself much more productive. See Claudio Lassala’s article, “Creating and Distributing Packages with the Visual Studio SDK” in this CoDe Focus issue to learn more about how to extend Visual Studio 2008 using VSPackages.

The Add-In Defined

Developers choose to automate the Visual Studio IDE to increase their productivity. How many times have you found yourself performing the same tasks for your projects? You create a new project, make standard settings changes, you add the same folder structure, you add the same programs, add the same references, etc. As you develop more and more applications you may find yourself spending more time doing redundant project setup and configuration. Add-ins help you cut out redundancy and allow you to focus on core development tasks. You can take this mundane set of steps out of the process by using a combination of add-ins, macros, and templates.

Creating the Basic Add-In

As your first step you want to create the basic shell of your add-in. To create an add-in in Visual Studio, do the following:

  1. From the Visual Studio menu select File and choose New Project.
  2. In the New Project dialog box (Figure 1) in the left pane, select Other Project Types, expand the Extensibility type, and in the right pane choose Visual Studio Add-In and then click OK.
  3. Name your project. For this example I’ll use CodeFocusAddIn.
  4. The Add-In Wizard will then start up. On page 1 you need to specify the language you will use to develop your add-in. You can choose from Visual Basic, C#, J# and two styles of C++ development. In the add-in for this article, I’ll use Visual Basic.
  5. Page 2 allows you to specify the host(s) for your add-in. By default the hosts are Visual Studio 2005 and Visual Studio 2005 Macros. Choose the host(s) you wish to support.
  6. On page 3 you’ll provide the name and description of your add-in.
  7. Now you’ll specify some options for your add-in (Figure 2). On page 4, specify whether your add-in will be called from the toolbar, whether you want the add-in to load when the Visual Studio Shell starts, and whether the add-in will activate any modal forms. In the project for this article, I’ll choose to add an option to the toolbar.
  8. Page 5 allows you to provide information in the “About” box for your add-in.
  9. Finally on page 6 click Finish. The wizard will create your add-in project and all supporting files.

Click for a larger version of this image.

Figure 1: Visual Studio Shell options to create a new add-in.

Click for a larger version of this image.

Figure 2: New add-in dialog box with options specified to add a toolbar item and auto load the add-in into the host application.

At this point you want to look at two specific files: <your-project-name>.AddIn and Connect.VB. The .AddIn file contains XML information that is used to register your add-in with the Visual Studio shell. Listing 1 contains the contents of this XML.

The Connect.VB file contains the guts of your add-in. This code implements two interfaces: IDTExtensibility2 and IDTCommandTarget, which the Visual Studio IDE uses to communicate with your add-in. To add custom code to your add-in you’ll use the Connect.VB. file.

&

By: Rod Paddock

Rod Paddock is the editor of CoDe Magazine. Rod has been a software developer for more than 10 years and has worked with tools like Visual Studio .NET SQL Server, Visual Basic, Visual FoxPro, Delphi and numerous others.

Rod is president of Dash Point Software, Inc. Dash Point is an award winning software development firm that specializes in developing applications for small to large businesses. Dash Point has delivered applications for numerous corporations like: Six Flags, First Premier Bank, Intel, Microsoft and the US Coast Guard.

Rod is also VP of Development for SQL Server tools maker, Red Matrix Technologies. (www.redmatrix.com).

Fast Facts

Visual Studio 2008 add-ins, combined with the Visual Studio object model and templates, create a useful way to customize the Visual Studio 2008 IDE.



Listing 1: .addin file created for a new Visual Studio add-in
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<Extensibility 
   xmlns="http://schemas.microsoft.com/AutomationExtensibility">
<HostApplication>
   <Name>Microsoft Visual Studio Macros</Name>
   <Version>8.0</Version>
</HostApplication>
<HostApplication>
   <Name>Microsoft Visual Studio</Name>
   <Version>8.0</Version>
</HostApplication>
<Addin>
   <FriendlyName>CodeFocusAddIn </FriendlyName>
   <Description>
       CodeFocusAddIn - Used to create complex solutions 
       automatically.
      </Description>
   <Assembly>CodeFocusAddIn.dll.dll</Assembly>
   <FullClassName>CodeFocusAddIn.Connect</FullClassName>
   <LoadBehavior>1</LoadBehavior>
   <CommandPreload>1</CommandPreload>
   <CommandLineSafe>0</CommandLineSafe>
</Addin>
</Extensibility>


Article Pages:  1  2 3 - Next Page: 'Modifying Your Add-In Code' >>

Page 1: Creating Visual Studio Add-Ins
Page 2: Modifying Your Add-In Code
Page 3: Creating Project Templates

How would you rate the quality of this article?
1 2 3 4 5
Poor      Outstanding

Tell us why you rated the content this way. (optional)

Average rating:
1.8 out of 5

141 people have rated this article.

TOWER 48

      CODE Training

 

DevTeach