vb6 中的 SxS .NET COM:ActiveX 组件无法创建对象?

问题描述

我正在尝试让我的 .NET COM dll 与我的 VB6 应用程序并行工作 (SxS)。我想并排使用(带有清单文件),这样我就可以在不注册库的情况下运行应用程序。经过反复试验,我似乎已经让它工作了。 TLB 文件正在 VB6 项目中被引用,所有方法都在显示。现在唯一的问题是,当我调试 VB6 应用程序时,它会在使用类库时导致 delimiter = "\n" # or some custom pattern that won't occur in the string def break_line(match): return delimiter + match.group() lines = re.sub(regex_pattern,break_line,text_you_want_to_split) lines = re.split(delimiter,lines) 错误

ActiveX component can't create object

Visual Studio 6 编辑器说一切都很好。当我将应用程序编译为 EXE 文件时,它甚至可以毫无问题地运行。 Visual Studio 6 是否做了一些奇怪的事情来阻止在调试时使用 Side by Side dll?

一些额外的信息: 类库是为 .NET Framework 4 创建的,它是 COM 可见的,并且启用了 COM 互操作。生成了 TLB 文件,并且已经用 mt.exe 生成一个清单文件


更新 1:由于 regsvr32 和 regasm 都无法注册我的 DLL 文件,我可能会添加一些有关如何构建 COM 程序集的信息。

我遵循了 Microsoft 的演练:Walkthrough: Creating COM Objects with Visual Basic。本演练使用 COM 类模板。这是我在 Private Sub Command1_Click() Dim myCustomer As New Customer myCustomer.Address = "test" <--- Error occurs here MsgBox myCustomer.Address Set Client = nothing End Sub 类中的最终代码

Customer

在项目设置中 a 已选中 <ComClass(Customer.ClassId,Customer.InterfaceId,Customer.EventsId)> Public Class Customer #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 = "08dbe20f-48b9-4ea3-8b19-7dbc3df311fa" Public Const InterfaceId As String = "f10cc4d2-b073-4c70-82c4-9fd393dea1e4" Public Const EventsId As String = "b13afd62-c892-40d7-aa60-d0a00993f4b7" #End Region ' A creatable COM class must have a Public Sub New() ' with no parameters,otherwise,the class will not be ' registered in the COM registry and cannot be created ' via CreateObject. Public Sub New() MyBase.New() End Sub Private _Name As String = "Initial value" Private _Address As String = "Initial value" Public Sub SetName(Value As String) _Name = Value End Sub Public ReadOnly Property Name As String Get Return _Name End Get End Property Public Property Address As String Get Return _Address End Get Set(value As String) _Address = value End Set End Property End Class Make assebmly COM-Visible 的复选框。当我构建项目时,我得到一个 DLL 文件一个 TLB 文件。之后,我通过使用以下参数运行 mt.exe 创建一个清单文件Register for COM interop生成的 3 个文件正在复制到我的 VB6 项目文件夹中。在 Visual Studio 6 中,我现在选择 TLB 文件作为参考,我可以开始编码。我使用资源编辑器在位置 1 添加了 DLL 的清单文件。这就是全部。现在我的 VB6 应用程序的编译版本使用 .NET COM 程序集,没有任何错误。但是从 Visual Studio 6 编辑器中调试 VB6 项目是原始问题中提到的问题。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)