When you build a VSTO solution the code is compiled, the necessary assemblies are created and the project is output to the \bin directory.
There are 3 files created:
ExcelWorkbook.dll - Assembly associated with this project. This file has the application manifest embedded inside it.
ExcelWorkbook.pdb - Program Database file which stores information needed to debug yout assembly.
ExcelWorkbook.xls - The project file in this case a copy of the workbook.
Whenever you build a VSTO project the /bin directory is automatically granted with full trust.
Open Windows Explorer and browse to the following folder
C:\Visual Studio\ExcelWorkbookTutorial\ExcelWorkbookTutorial\bin\Debug \
ExcelWorkbookTutorial.xlsx - This is the workbook which you want to link the code to
ExcelWorkbookTutorial.vsto - This is the deployment manifest and contains version information and the location of the application manifest
ExcelWorkbookTutorial.dll.manifest - This is the application manifest and contains all the necessary information required to install and run the assembly file
The following two files do not need to be deployed
ExcelWorkbookTutorial.dll - This is the assembly for the project which is the file that actually contains your code
ExcelWorkbookTutorial.pdb - This is the program database file (or symbol file) which maps the identifiers in your source code to those in the compiled executable. This file is often required for debugging purposes.
If you want the code files saved in a different location to the workbook then we need to make a small change to the workbook file properties.
File Custom Properties
Remember that the code is not saved in the Office file but is saved in a separate dll file.
There is a reference to this code file in the file properties.
Double click on the ExcelWorkbookTutorial.xlsx file to open it and press OK on the message.
Select (File > Prepare > Properties)
Choose Document Properties drop-down in the top left and select Advanced Properties
Select the Custom tab
There are two custom properties that have been added to this workbook:
_AssemblyLocation - ExcelWorkbookTutorial.vsto|db7898a4-4611-49e1-b0a0-5d90cfcf03d8|vstolocal
This contains the name and the folder location of the Visual Studio Deployment Manifest file combined with the Global Unique Identifier (GUID) that identifiers your particular assembly.
The vstolocal term indicates that the assmebly will be loaded from the same folder as the workbook
If the solution has been published (to a website, UNC etc) then this property will have a slightly different format (file://deployserver/MyShare/ExcelWorkbookTutorial.vsto| db7898a4-4611-49e1-b0a0-5d90cfcf03d8
_AssemblyName - 4E3C66D5-58D4-491E-A7D4-64AF99AF6E8B
This contains the CLSID that refers to the entry point interface in the VSTO Loader. This should not be changed.
When someone opens an Office file the Microsoft Office application checks to see of these custom document properties exist. If they do then the application loads the Visual Studio Tools for Office runtime and loads the corresponding manifests and assemblies.
© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext