0

接口实现类

[ComVisible(true)]
    [Guid("13FE32AD-4BF8-495f-AB4D-6C61BD463EA4")]//GUID for this class
    [ClassInterface(ClassInterfaceType.None)]//Donot generage any interface automatically.  We will explicitly create one
    [ComSourceInterfaces(typeof(IMathInterface))]//Expose events
    [ProgId("CCWTEST.ClassMath")]//Friendly name of the class. Used while creating object without using 'New' keyword
    public class ClassMath : IMathInterface
    {
        [ComVisible(true)]
        int IMathInterface.Add(int x, int y)
        {
            return x + y;
        }
    }

界面

[ComVisible(true)]
    [Guid("D6F88E95-8A27-4ae6-B6DE-0542A0FC7039")]//GUID for this interface
    [InterfaceType(ComInterfaceType.InterfaceIsDual)]//Enable early as well as late binding
    public interface IMathInterface
    {
        [DispId(1)]
        int  Add(int i, int j);
    }

Javascript

window.onload = onLoad;
        function onLoad()
        {
            try
            {                
                var obj = new ActiveXObject("CCWTEST.ClassMath");           

            }
            catch (e)
            {
                alert(e.Message);
            }
        }

我已经创建了 windows 窗体类类型库。DLL 业务逻辑必须在 Asp.net 页面中使用。为此,
在 Wrapper 类中生成了一个 CCW Wrapper 类,为函数声明创建接口。并在包装类中实现接口函数。使所有功能 [comvisible=true]

在 GAC 中注册 dll。现在必须在 asp.net 页面中使用所以创建了 ActiveXObject。它给了我例外“未定义”

4

0 回答 0