从VB6调用VB.NET COM类时类型不匹配 [英] Type mismatch when calling a VB.NET COM class from VB6

查看:251
本文介绍了从VB6调用VB.NET COM类时类型不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我必须用VB.NET实现COM类.然后必须从VB6 DLL创建此类的对象. COM dll的代码非常简单:

Hi all,

I have to implement a COM class with VB.NET. An object of this class has then to be created from a VB6 DLL. The code for the COM dll is very simple:

Public Class AdapterWrapper
    Implements SchemaCompInterfaces.IEFAdapter

#Region "COM-GUIDs"
    Public Const ClassId As String = "58faad86-bbac-4b20-9ab5-fe32bdac0a68"
    Public Const InterfaceId As String = "f8dbb078-5f1e-4304-a390-3e8e88983f98"
    Public Const EventsId As String = "113d2163-f8db-4d99-88e5-58d13b8d2cf4"
#End Region
   
    Public Sub New()
        MyBase.New()
    End Sub
    Public WriteOnly Property CurrentSPFProjectStatus() As SchemaCompInterfaces.SPFProjectStatus Implements SchemaCompInterfaces.IEFAdapter.CurrentSPFProjectStatus
        Set(ByVal value As SchemaCompInterfaces.SPFProjectStatus)
        End Set
    End Property
    Public Function DocumentExistsInTool(ByRef oDocumentIObj As SchemaCompInterfaces.IObject) As Boolean Implements SchemaCompInterfaces.IEFAdapter.DocumentExistsInTool
    End Function



从IEFAdapter接口继承更多功能...
dll和tlb已创建并注册.

VB6客户端使用此COM类的测试代码也非常简单:



Following many more functions from the IEFAdapter interface...
The dll and tlb are created and registered.

The test code for the VB6 client to use this COM class is also very simple:

Private Sub Command1_Click()
  Dim adapter As SchemaCompInterfaces.IEFAdapter
  Set adapter = Interaction.CreateObject("MyEFAdapter.AdapterWrapper")    
End Sub



现在,当我运行此代码时,我在CreateObject行中遇到运行时错误"13",输入类型不匹配.与
的后期绑定



Now when I''m running this code, I''m getting the Run-time error ''13'' Type mismatch in the CreateObject line. Late binding with

Dim adapter as Object

似乎适用于我的测试代码,但对我来说却不是解决方案,因为我无法更改创建COM对象的专有VB6代码.因此,以某种方式不知道接口"SchemaCompInterfaces.IEFAdapter" ...:sigh:

有什么想法可以解决这个问题吗?
在项目属性中,我检查了用于向COM-Interop注册的标志.也许与ClassInterface有关?

我对VB比较陌生,所以不要回答太复杂...;)

提前谢谢!
Alex

seems to work for my test code, but is not a solution for me, because I can''t change the proprietary VB6 code where the COM object is created. So somehow the interface "SchemaCompInterfaces.IEFAdapter" is not known... :sigh:

Any ideas how to get close to this problem?
In the project properties I checked the flag for registration with COM-Interop. Perhaps something to do with the ClassInterface?

I''m relatively new to VB, so don''t answer too complex... ;)

Thanks in advance!
Alex

推荐答案

也许您需要在项目属性的编译"选项中选中注册COM互操作"复选框.

这将注册您的项目的类型库,并可以在VB6中使用
Perhaps you need to Check "Register COM Interop" Checkbox in Compile option in project properties.

This will register the type library of your project and can be used in VB6


这篇关于从VB6调用VB.NET COM类时类型不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆