COM Visible Assembly - Object method not accessible through its exposed interface method

守給你的承諾、 提交于 2019-12-13 16:21:20

问题


I implemented a .NET DLL with COM visibility (VB.NET):

Public Class Processer Implements IProcesser
    Public Sub processASpecificThing(ByVal param As String) _
        Implements IProcesser.processAThing
        ' [...]
    End Sub
End Class

Below the Interface definition. For some reasons I exposed a method with a different name in the interface.

Imports System.Runtime.InteropServices
Imports System.ComponentModel

<InterfaceType(ComInterfaceType.InterfaceIsDual)> _
Public Interface IProcesser
    Sub processAThing(ByVal param As String)
End Interface

The project is configured to set the Assembly as COM visible. If I understood correctly InterfaceIsDual let the Interface be visible at early binding as well as at late binding.

In a VB6 project, this works:

Dim aProcesser as IProcesser
Set aProcesser = New Processer
aProcesser.processAThing "param" ' Call by the *Interface* method name

In a VB6 project or an ASP classic VBScript page, this fails:

Dim aProcesser
Set aProcesser = CreateObject("ProcessLib.Processer")
' Call by the *Interface* method name
aProcesser.processAThing "param" ' [FAIL]           
' Call by the *Interface* method name
aProcesser.processASpecificThing "param" ' [SUCCESS]

The failing line leads to the error message:

Object Doesn't Support this Property or Method

The real context of this question is an ASP classic page. I use a late binding to avoid adding a METADATA header in the ASP file (I believe it's the only way, but not tested yet).

Sounds like the interface is not accessible. Why does that problem occur and how could I make the interface accessible with ?

来源:https://stackoverflow.com/questions/56075539/com-visible-assembly-object-method-not-accessible-through-its-exposed-interfac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!