首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

有关com的互操作的有关问题

2012-01-28 
有关com的互操作的问题我用c#写了一个类库,代码如下:usingSystemusingSystem.Collections.GenericusingS

有关com的互操作的问题
我用c#写了一个类库,

代码如下:

using   System;
using   System.Collections.Generic;
using   System.Text;
using   System.Runtime.InteropServices;

        namespace   CLJC
        {
                [Guid( "18E2BCAF-F4B5-4031-8F84-FCFB1DC04877 ")]  
                [InterfaceType(ComInterfaceType.InterfaceIsDual)]
                public   interface       I
                {
                        string   f();
                }
                [Guid( "2e726b07-c820-42b5-ab0b-5581b443bf05 ")]
                [ClassInterface(ClassInterfaceType.AutoDual)]
                public   class   lc   :   I
                {
                        public   string   f()
                        {
                                return   "liujicnai ";
                        }
                }

        }

我用了强名称。

生成dll后。
执行
regasm   /tlb:cl.tlb   cl.dll

gacutil   /i   cl.dll

进行注册

然后创建一个vb应用程序,引用这个组件。
但是不能用
我写一句代码     dim   a   as   CLJC.lc  
运行程序,出错,错误为:
用户定义类型未定义

郁闷。大家谁做过   把.net组件封装成   标准com   的工作。
请指教

[解决办法]
关注一下
[解决办法]
关注一下

热点排行