How does Excel VSTO Work?

calendar_today Asked Feb 11, 2009
thumb_up 7 upvotes
history Updated April 16, 2026

Question posted 2009 · +8 upvotes

How does Excel VSTO Work? If I create an Excel Workbook solution in Visual Studio 2005 I can then happily code away with full access to the Excel object model and even treat the Excel sheet as a design surface. When I build the solution I get a .XLS file and a .DLL (containing my C# code).

I can now start up the Excel sheet just by double clicking on the .XLS and there is my sheet functioning with all my C# code and any controls I dropped on the sheet etc.

How is the sheet referencing the .DLL? What part of the excel workbook/sheet tells it that it needs to fire up the CLR and host my assembly?

Accepted answer +7 upvotes

According to this (thanks PintSizedCat) for Excel 2003 the following happens:

The Microsoft Office application checks the custom document properties to see whether there are managed code extensions associated with the document. For more information, see Custom Document Properties Overview.

If there are managed code extensions, the application loads AddinLoader.dll. This is an unmanaged DLL that is the loader component for the Visual Studio 2005 Tools for Office Second Edition runtime. For more information, see Visual Studio Tools for Office Runtime Overview.

AddinLoader.dll loads the .NET Framework and starts the managed portion of the Visual Studio Tools for Office runtime.

The Visual Studio Tools for Office runtime creates an application domain, sets policy for the application domain not to trust the My Computer Zone, and checks the code access security policy store to find a policy for the customization assembly.

The .NET Framework validates the evidence presented by the assembly against the policy. If it fails, an error is raised. If it passes, the process continues.

If the customization uses a deployment manifest, the Visual Studio Tools for Office runtime uses it to check for assembly updates. If any updates are necessary, they are performed now.

The Visual Studio Tools for Office runtime loads the assembly into the application domain.

The Visual Studio Tools for Office runtime calls the Startup event handler in your customization assembly. For more information, see Visual Studio Tools for Office Project Events.

In my test project’s Excel workbook I have two custom properties:

_AssemblyName, value = * _AssemblyLocation, value = {533b2c13-a125-418a-bfff-9546b0762807}

I suppose these are the properties which direct the VSTO runtime to my assembly.

Top excel Q&A (6)

+7 upvotes ranks this answer #122 out of 167 excel solutions on this site .