Visual Studio 2008 Scalability Development (iii): Analysis of the operating mechanism of add-in (i)

Source: Internet
Author: User

Objective

The previous essay macro and add-in a brief introduction of how to develop both the HelloWorld program. Yes, macros are simple and easy to do. But in some cases, such as in business software, macros can cause problems in terms of performance and intellectual property, and the better Hammer is add-in.

In this article, I introduced how to use the Add-in Wizard to develop the first add-in. VS is a great development tool, with its various wizards (and other templates, visualization tools, and so on) doing very well, but I find that this strong point in the end is a criticism. One argument is that these handy tools make beginners easy to get started with and spoil them so that it's much harder to go in. Objectively speaking, this is not a vs fault, VS doesn't stop you from understanding the tools behind them. These tools generate a lot of code, and we need to take the initiative to get to know them, as mentioned in the programmer's Way of cultivation:

Don ' t use Wizard Code for you don ' t understand

Obviously, the author is not saying that you can't use the wizard, but that you want to use it if you understand the wizard. Especially if the code you write is mixed with the code generated by the wizard, this code will eventually become your code, and Add-in's development is so! So we have to understand what the Add-in Wizard did.

The Add-in Wizard collects information

The Add-in Wizard has a total of six steps, and each step we can enter a certain information to tell vs how to set. This can be seen as the process by which the wizard collects information, including:

Programming Language: You can choose C #, vb.net, VC, if it is hand-written add-in, there is no limit

Hosting environment: Add-in can be run simultaneously in different versions of the VS IDE and/or macro IDE

Name and description

menu commands: vs generate some code to add a new menu item to the Tools menu

Command-line run support: Such add-in shows that it does not render UI that requires user intervention, such as a modal dialog box

Load at startup: vs can be loaded automatically at startup add-in

About dialog: You can display add-in information in the About dialog box

When the information is gathered, VS will generate a new add-in project.

Add-in Project

The Add-in project is a class library project (which you can refer to as an example in the article), that's all. The project contains the "Connect.cs" file, which defines the Connect class and a configuration file Firstaddin.addin.

Open the Connect.cs and we'll analyze it carefully. The Connect class implements two interfaces, one is IDTExtensibility2, the interface is used to communicate between the add-in and the IDE, and the second is IDTCommandTarget, if you select the UI option in the wizard, you need to implement it.

IDTExtensibility2 contains 5 methods:

OnConnection: Called when loading add-in

OnStartupComplete: Called after add-in completes loading with VS

OnAddInsUpdate: Called when vs load or unload add-in

OnBeginShutdown: called on vs Close

OnDisconnection: Called when Add-in is unloaded

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.