1

我尝试了链接如何从 Visual Basic 6.0 调用 Visual Basic .NET 或 Visual Basic 2005 程序集中的简单应用程序

.net 代码

    <ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
    Public Class ComClass1

    #Region "COM GUIDs"
        ' These  GUIDs provide the COM identity for this class 
        ' and its COM interfaces. If you change them, existing 
        ' clients will no longer be able to access the class.
        Public Const ClassId As String = "6DB79AF2-F661-44AC-8458-62B06BFDD9E4"
        Public Const InterfaceId As String = "EDED909C-9271-4670-BA32-109AE917B1D7"
        Public Const EventsId As String = "17C731B8-CE61-4B5F-B114-10F3E46153AC"
    #End Region

        ' A creatable COM class must have a Public Sub New() 
        ' without parameters. Otherwise, the class will not be 
        ' registered in the COM registry and cannot be created 
        ' through CreateObject.
        Public Sub New()
            MyBase.New()
        End Sub

Public Function myFunction() As Integer
      Return 100
   End Function

    End Class

VB6代码

Dim myObject As TestProj.COMClass1
Set myObject = New TestProj.COMClass1
MsgBox myObject.myFunction

它可以在我的开发机器上使用 .Net 4.0 和 VS 2010 和 VB6。当我将文件复制到 Windows Server 2008 R2 机器并使用格式 Regasm AssemblyName.dll /tlb: FileName.tlb /codebase 注册程序集并强烈签署程序集时,我收到错误 429 无法创建 ActiveX 组件。我检查了注册表,并在其中看到了 classid。我错过了什么?谢谢

另外,我有一个旧版 vb6 应用程序,它使用 RDS(远程数据服务)在使用 Com+ 的另一台服务器上创建对象,但我只想更改它以在与 vb6 exe 相同的服务器上运行 .Net dll。有没有办法从另一台客户端 PC 在服务器上运行 exe 而无需注册 .Net dll (tlb) 或者我是否需要创建一个 setup.exe 来打包所有内容?我试图在我的 Virtual XPMode 上运行相同的 exe,即使我创建了一个安装应用程序,我也会遇到同样的错误。它只适用于我的开发机器。

4

0 回答 0