Com-Visible .net 4.0 assembly with PowerBuilder 9

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ravi L
    New Member
    • Oct 2010
    • 12

    Com-Visible .net 4.0 assembly with PowerBuilder 9

    Hi There,(Com-Visible .net 4.0 assembly with PowerBuilder 9)

    I have a peculiar issue with .net 4.0 assembly which is com-visible. We have a requirement where a powerbuilder application is supposed to invoke a method from a .net 4.0 assembly (dll). The following code is making the .net 4.0 dll com-visible.

    <ComVisible(Tru e)> _

    <ClassInterface (ClassInterface Type.AutoDual)> _

    <ProgId("NamesS pace.ClassName" )> _

    <Guid("123412 EB-ABCD-46C8-A902-123AC6EB466E")> _

    <Serializable() > _

    Public Class ClassName

    It works perfectly when built using .net 2.0. but fails when using .net 4.0. when we try to connect to the assembly from powerbuilder it fails to connect and errors our with a "Cannot create an object" error. We tried building from a different machine and found that when built from a different machine even the .net 4.0 com-visible component works. It is able to connect.

    The issue now is "The com-visible .net 4.0 assembly works when built from some machines and does not work when built from other machines." what may be the reason for this.

    Any light on this will be really appreciated.

    Thank you in advance.
  • Ravi L
    New Member
    • Oct 2010
    • 12

    #2
    Got this working. Posting the solution I got. It may help somebody in distress.

    Declare an interface as below:
    Code:
    <InterfaceType(ComInterfaceType.InterfaceIsIDispatch)> _
    Public Interface _IInterfaceName
    <DispId(1)> Function FunctionName(ByVal parameter As String) As ReturnType
    End Interface
    Now the functions to be exposed via COM will be in the class as below:

    Code:
    Public Class ClassName
           Implements _IInterfaceName
    
    Public Function FunctionName(ByVal parameter As String) As ReturnType Implements _IInterfaceName.FunctionName
    
    'Function Implementation
    
    End Function
    End Class
    Hope this helps.

    Comment

    Working...