Visual Studio Tools for office Architecture

Source: Internet
Author: User

You can use Visual Studio Tools for office to create two types of solutions: Document-level custom items and applications.ProgramLevel External program. They have the following configurations:

    • Document-level custom items are hosted by Microsoft Office Word documents or Microsoft Office Excel workbooksCodeAssembly.

    • An application-level external program consists of a managed code assembly that runs as an external program in a Microsoft Office application.

Applications developed using Visual Studio Tools for office are CLR-based hosted applications, while office is an unmanaged Application Based on COM components. therefore, it is necessary to review the process of hosting applications in CLR. the Code is as follows:

Code
Class Program
{
Static   Void Main ( String [] ARGs)
{
Console. writeline ( " Hello word " );
}
}

Flow chart for execution

Let's briefly talk about the execution process,. net ide calls the csc.exe compiler to generate the EXE assembly. take the 32-bit operating system as an example. when the EXE assembly is executed, a 32-bit process is created in the first line. The main thread in this process calls mscoree. DLL component to initialize CLR, mscoree. the DLL is located in the c: \ windows \ system32 directory to determine whether a machine is installed. net Framework. in the first example, the CLR loads the EXE assembly and runs the program starting from the main () function entry point. The CLR allocates a separate internal structure for the console type called in the main method, and pay the address for each method of this type so that this method can be used for calling. When the writeline () method is called for the first time, the JIT compiler is called, the JIT compiler looks for the writeline method from the metadata and compiles the CPU code at the cost. and modify the writeline pointer stored in the console type, so that the second call to the writeline method can directly execute local CPU code. in addition, the metadata is supplemented. There are two metadata tables, one of which is a type table, for example, used to check the parameter types during compilation. the other is the member table. describes the members of the managed module. the execution process of managed applications is introduced here. The following describes the execution process of office applications.

Two solutions created by vsto, whether document-level custom items or application-level external programs, are deployed by the Office document and assembly (DLL file. when you open the managed code Office document, the vsto loader starts the vsto runtime ), create an application domain and set the policy of this application domain to the "my computer" area without trust. then, the vsto Runtime Library initializes the Common Language Runtime Library (CLR) to the application domain. the initialized CLR loads the managed assembly corresponding to the document. through the main interoperability Assembly PIA (Adapter) To capture events in the Document. Next, let's talk about the process of calling the assembly in the office document.

1. Architecture of document-level custom items

1). 2007 Microsoft Office System customization Architecture

 

No matter document-level custom items or application-level external programs, pointers exist to save the address of the linked hosted assembly. the _ assemblylocation attribute is provided in the office2007 document to store the deployment list. when you open a document that belongs to the 2007 Microsoft Office custom, the application reads the deployment list from _ assemblylocation. then read the Application List from the deployment list. to find the latest document-level custom item assembly. the custom Assembly communicates with the office COM component through the main interoperability Assembly Pia.

 

2). Custom definition architecture of Microsoft Office 2003

 

 

In office2003 document-level custom items, the difference is thatRuntime storage controlsTo save the Application List. when you open a document that belongs to the 2003 Microsoft Office custom, the application reads the Application List from the Runtime storage control. the Application List loads an optional deployment list to find the latest document-level custom item assembly. the custom Assembly communicates with the office COM component through the main interoperability Assembly Pia.

It is necessary to mention that vsto runtime 3.0 and vsto runtime 2.0 Load components differently. in vsto runtime 3.0, the application first loads vstoee. DLL component, and then load vstoloader. DLL component to initialize the public Language Runtime Library. in vsto runtime 2.0, only addinloader is provided. DLL to initialize the public Language Runtime Library.

 

2. Architecture of application-level external programs

1). 2007 external program architecture of Microsoft Office System

 

 

Compared with document-level custom item programs, application plug-ins discover applications by registering. when the user opens the external program document of the 2007 Microsoft Office application. the application reads the registry key and then reads the deployment list. read the Application List from the deployment list to find the latest External Application assembly. the external program Assembly communicates with the office COM component through the main interoperability assembly (PIA.

2). External program architecture of Microsoft Office 2003

 

 

Compared with Microsoft Office 2007. the process of loading the external program assembly is basically the same. the difference is that the Application List loads the available deployment list to find the latest external program assembly. The external program Assembly communicates with the office COM component through the main interoperability assembly (PIA.

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.