An Automation Interface is a class designed to be loaded in Spotfire to enable remote control. The public methods of this class will be COM visible and can thus be called by an automation client.
Overview
This topic provides implementation details on how to create an automation interface for Spotfire. Refer to Creating an Automation Interface for general information and insight into the relation between the objects and executables involved.
Prerequisites
Spotfire SDK\Examples\COM Automation\SpotfireDeveloper.ComAutomationExample
The project contains the following: Class library project with an example view
The project has methods to open and close the document, and RegisterCallback method allowing the view to relay events in Spotfire to the client.
JavaScript web page client
This client is simple and straightforward. Since it depends on ActiveX® it needs to be opened using Internet Explorer®.
Stand alone .Net client
COM interaction from .Net is more complicated since it relies on late binding. The strategy is to wrap all COM objects in a way that allows them to expose a strongly typed API.
Launching Spotfire from a remote client
Spotfire can be launched from another application by instantiating it as an ActiveXObject. A script client can do it by the following call:
controller = new ActiveXObject("Spotfire.Dxp");
A .NET client in C# can do the same by the following call:
object controller = Activator.CreateInstance(Type.GetTypeFromProgID("Spotfire.Dxp"));
The controller object returned has a minimal API for controlling Spotfire.
Implementing a COM visible view
The type of the objects created with ILoadViewsContext.CreateObjectFrom() must derive from AnalysisApplicationComView. Mark your class with the following attributes:
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[Guid("IMPORTANT-TO-CREATE-YOUR-OWN-GUID!")]
The public methods in this class will be COM visible and available to the automation client. Call the protected InteractOnApplicationThread() method to interact with the application or document on the correct thread.
Debugging
- Open the project that contains your COM view in Visual Studio®.
- Right-click the project, select Properties and then the Debug tab.
- In the Start Action section, select the Start external program and browse to
Spotfire.Dxp.exe.
- In the Command line arguments input box, enter
/Automation.
- Press F5 to start debugging.