建立了类库工程CLS(C#)
想在VB下调用该类,应该怎么办啊

解决方案 »

  1.   

    using System;
    public interface ICSharp
    {
       string GetResponseFromCSharp();
    }namespace CallFromCom
    {
      public class CallCSharp : ICSharp
      {
         public string GetRepoonseFromCSharp()
         {
            return "Hello from C#!";
         }
      }
    }
    编译上面代码为CallFromCom.dll
    RegAsm CallFromCom.dll /tlb:CallFromCom.tlb
    这个命令行把C#库作为COM组件注册VB
    Private Sub Command1_Click()
       Dim myCSharp As New CallCSharp.CallCSharp
       mystring = myCSharp.GetResponseFromCSharp()
       response = MsgBox(mystring, vbOKOnly,"Response From C#")
    End Sub
      

  2.   

    看msdn的帮助:
    http://msdn.microsoft.com/library/cht/default.asp?url=/library/CHT/cptools/html/cpgrfassemblyregistrationtoolregasmexe.asp
      

  3.   

    wangsaokui(无间道III(MSMVP)) 大哥我把你上面的代码放到TT2工程内
    这个会提示错误,找不到文件或程序集名称TT2,或者找不到他的一个依赖项