非常实用的东西!过去知道这个方法的话可以解决多少问题啊
首先建立一个C#的DLL工程,写一个类
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
,编译
然后在cmd里执行VS的vsvars32.bat设置环境变量,然后执行
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
Microsoft (R) .NET Framework 程序集注册实用工具1.1.4322.573
版权所有 (C) Microsoft Corporation 1998-2002。保留所有权利。
RegAsm 警告: 使用 /codebase 注册未签名的程序集可能会导致程序集妨碍在同一台计算机
上可能安装的其他应用程序。/codebase 开关旨在仅用于已签名的程序集。请为您的程序集
提供一个强名称并重新注册它。
成功注册了类型
程序集已被导出到“C:\Documents and Settings\pyw\My Documents\Visual Studio Proje
cts\cscomtest\bin\Debug\cscomtest.tlb”,类型库注册成功
然后打开VB或者VBS,写KO!成功了,这个效果相当于用VB调用C#,虽然是通过COM实现的,太酷了!
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)