首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从dll依赖项创建CCW

如何从dll依赖项创建CCW
EN

Stack Overflow用户
提问于 2013-05-29 12:20:07
回答 1查看 416关注 0票数 2

我正在为C#类库创建一个CCW组件,这个库包含一些第三方DLL。

  1. 此用户控件必须在经典Asp页面中使用
  2. 为此目的,生成了一个CCW包装类。
  3. 在包装类中,为函数声明创建接口。

此接口和类包含C#类库DLL和第三方DLL的引用。

接口

代码语言:javascript
复制
[ComVisible(true)]
    [Guid("D6F88E95-8A27-4ae6-B6DE-0542A0FC7039")]//GUID for this interface
    [InterfaceType(ComInterfaceType.InterfaceIsDual)]//Enable early as well as late binding
    public interface IInterface
    {
        [DispId(1)]
        void Init();

        [DispId(2)]
        void OpenFile(string FileName);

        [DispId(3)]
        void Dispose();

        [DispId(4)]
        THirdPartyDLLClass ThirdPartyMethod();
    }

接口实现类

代码语言:javascript
复制
    [ComVisible(true)]
    [Guid("13FE32AD-4BF8-495f-AB4D-6C61BD463EA4")]//GUID for this class
    [ClassInterface(ClassInterfaceType.None)]//Don't generate any interface  automatically.  We will explicitly create one
    [ComSourceInterfaces(typeof(IInterface))]//Expose events
    [ProgId("CCWTEST.ClassMath")]//Friendly name of the class. Used while creating object without using 'New' keyword
    public class ClassMath : IInterface
    {
      [ComVisible(false)]//Don't expose to COM. Can be used internally.
      private ViewerControl objViewerControl = new ViewerControl(); //ref dll class file

      [ComVisible(true)]
       public void Init()
        {
         objViewerControl.Init();
        }

       [ComVisible(true)]
        public void OpenFile(string FileName)
         {
          objViewerControl.OpenFile(FileName);
         }

       [ComVisible(true)]
        public void Dispose()
         {
          objViewerControl.Dispose();
         }

       [ComVisible(true)]// 
        public THirdPartyDLLClass  ThirdPartyMethod()
         {
           return THirdPartyDLLClass.ThirdPartyClassProperty;
          }
       }

JavaScript在经典ASP

代码语言:javascript
复制
window.onload = onLoad;
        function onLoad()
        {
            try
            {                
                var obj = new ActiveXObject("CCWTEST.ClassMath");           

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

在将这个DLL注册到gacutil /i并尝试将这些dll访问到我的java脚本代码之后,它会给我一个“未定义”错误。我不知道这会有什么问题。为此,必须将第三方DLL以及C#类库安装到GAC中。

EN

回答 1

Stack Overflow用户

发布于 2013-06-04 22:39:57

尝试使用regsvr32.exe CCWTEST.ClassMath.ocx (您的COM .ocx组件文件)来注册COM组件。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16813738

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档