AddIn.RequestComAddInAutomationService Method (2003 System)
Returns an object in your add-in that can be used by other loaded add-ins.
Namespace: Microsoft.Office.Tools
Assembly: Microsoft.Office.Tools.Common (in Microsoft.Office.Tools.Common.dll)
Syntax
'Declaration
Protected Overridable Function RequestComAddInAutomationService As Object
'Usage
Dim returnValue As Object
returnValue = Me.RequestComAddInAutomationService()
protected virtual Object RequestComAddInAutomationService()
Return Value
Type: System.Object
An object that you want to expose to other add-ins.
Remarks
Override this method to expose an object in your add-in to other loaded add-ins. When your add-in is loaded, the Visual Studio Tools for Office runtime calls this method and assigns the return value to the Object property of a COMAddIn object that represents your add-in. Other add-ins can then access this COMAddIn object by using the Application.COMAddIns property that is provided in the object model of every Microsoft Office application.
Your implementation of RequestComAddInAutomationService must return an instance of a class that meets the following requirements:
The class must be public and have the ComVisibleAttribute attribute set to true.
The class must expose the IDispatch interface. There are two ways a class can do this:
The class can implement an interface that has the ComVisibleAttribute set to true, and the InterfaceTypeAttribute set to InterfaceIsIDispatch or InterfaceIsDual.
-or-
The class can have the ClassInterfaceAttribute set to AutoDual or AutoDispatch.
If the object you return does not meet these requirements, the Visual Studio Tools for Office runtime will throw an InvalidCastException after your implementation of the method is called.
The Visual Studio Tools for Office runtime calls RequestComAddInAutomationService before it calls the default ThisAddIn_Startup event handler in your add-in project. For more information about the ThisAddIn_Startup event handler, see Visual Studio Tools for Office Project Events.
Permissions
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.