This example shows how simple it is to integrate VSTA into a COM application using a generic proxy and VAO. The generic proxy can be used to expose any COM object model (type library) to VSTA without using proxygen. VAO is used to simplify the integration process.
Synopsis: The COMClient passes an IUnknown ptr to an instance of its COM object directly to the VSTA Addin via a Connector object:
pConnector->AssignHostObject(pDispMyCOMServer);
The VSTA Addin obtains the same instance of the COM Object as a System.__ComObject.
object obj = this.GetHostObject();
The VSTA Addin uses a reference to the COMInterop assembly (created with tlbimp MSDNCOMServer.dll ) to provide strong type information for the COM Object .
MSDNCOMServerLib.
IMyCOMServer myOM = obj as MSDNCOMServerLib.IMyCOMServer;
myOM.MySimpleCOMServerMethod();
This approach uses a generic proxy layer (no need to run proxygen) that exposes one method to the Addin author.
System.Object Connector.GetHostObject()
Although the sample macro does not demonstrate it, this hookup method can easily be hidden in a global property like 'Application' so that the Addin author can use normal syntax to access the Application object model:
Application.MySimpleCOMServerMethod();
updated download with ReadMe: ftp://ftp.summsoft.com/vsta/COMClientVAOv2.zip