Hi All,
I have a C# Class Library I created. It contains a form and one class.
I can access the one class from JScript OK, but when I try to access
the method that launches the from I get this error message:
"Class doesn't support Automation"
Here is an abbreviated sample of my code:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Expando;
using XMetaL;
namespace LinkManager
{
/// <summary>
/// Summary description for CrossReference.
/// </summary>
[Guid("1CEC3EE2-C33B-44b4-AD1C-C881F912D8C3"), ComVisible(true),
InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface ICrossRef
{
//void InitializeComponent();
[DispId(1)]
void ShowIDDialog();
[DispId(2)]
void InsertLink(XMetaL.Selection sel);
}
[Guid("4599F628-4741-43ad-BFBC-AEB68BE37E1F"),
ClassInterface(ClassInterfaceType.None), ComVisible(true)]
public class CrossReference : System.Windows.Forms.Form, ICrossRef
{
private System.Windows.Forms.TreeView treeDocument;
private System.Windows.Forms.ListBox lstParas;
private System.Windows.Forms.ComboBox cboTags;
private System.Windows.Forms.Button btnCancel;
private System.ComponentModel.IContainer components;
public XMetaL.Application XMApp;
private System.Windows.Forms.Button btnInsert;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem mnuNav;
private System.Windows.Forms.MenuItem mnuSelElem;
private System.Windows.Forms.MenuItem mnuActions;
private System.Windows.Forms.MenuItem mnuSetID;
private System.Windows.Forms.MenuItem mnuLink;
private System.Windows.Forms.MenuItem mnuExit;
private System.Windows.Forms.StatusBar sBarPath;
private System.Windows.Forms.ToolTip toolTip1;
public XMetaL.Document currdoc;
private System.Windows.Forms.MenuItem mnuLastElem;
public XMetaL.Range startnode;
Form CrossRef;
public CrossReference()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//XMApp = CreateObject("XMetaL.Application");
XMApp = new XMetaL.ApplicationClass();
currdoc = XMApp.ActiveDocument;
XMetaL.DOMNode docnode = (XMetaL.DOMNode)currdoc.documentElement;
startnode = currdoc.Range;
DisplayDomNode(0,docnode);
TagsInit();
selectid = "";
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
currdoc = null;
XMApp = null;
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
#endregion
public void InsertLink(XMetaL.Selection sel)
{
}
public void ShowIDDialog()
{
CrossRef = new CrossReference();
CrossRef.Show();
}
}
}
My JScript Code:
var LinkMan = new ActiveXObject("LinkManager.CrossReference");
LinkMan.ShowIDDialog();
TIA
Robert Jordan - 14 Sep 2005 20:38 GMT
Hi Nadia,
> I have a C# Class Library I created. It contains a form and one class.
> I can access the one class from JScript OK, but when I try to access
> the method that launches the from I get this error message:
> "Class doesn't support Automation"
If you want to access the class from JScript, you cannot
set ClassInterface(ClassInterfaceType.None). Set it
to AutoDual in this case.
But if you want to expose the class to JScript only and don't
then remove the ClassInterface attribute and the interface,
because it's usesless for JScript.
Rob