making a com class in vb 2005

elwin68elwin68 Member Posts: 153
I have made a very simple com class with a function in vb 2005 so i can call this function out of Navision 4.0 SP1.
The code is as follow:

Imports System.Runtime.InteropServices

<InterfaceType(ComInterfaceType.InterfaceIsIDispatch)> _
Public Interface INavisionTest
Function Add2Numbers(ByVal a As Integer, _
ByVal b As Integer) As Integer
End Interface

<ClassInterface(ClassInterfaceType.None)> _
Public Class NavisionTest
Implements INavisionTest

Public Function Add2Numbers(ByVal a As Integer, _
ByVal b As Integer) As Integer _
Implements INavisionTest.Add2Numbers
Return (a + b)
End Function
End Class

The function is working fine.
The only thing I noticed is when defining the automation control in Navision the automation server is showing 2 classes (INavisionTest and NavisionTest). So the interface and the class are shown.
The function is only working when the class NavisionTest is selected.

How can I show only the class NavisionTest in Navision when defining the automation control? ](*,)

Answers

  • ara3nara3n Member Posts: 9,257
    Make it a private interface? Protected?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • SteveOSteveO Member Posts: 164
    I think it's something along the lines of <ComVisible(false)>
    This isn't a signature, I type this at the bottom of every message
  • elwin68elwin68 Member Posts: 153
    Making the interface private or Protected or using ComVisible(FALSE) will hide the unused class.

    When you now use the automation control in navision you only see all the default COM methods and properties (Equals, GetHashCode, GetType, ToString etc.).

    The custom made function Add2Numbers is not accessable anymore.
  • SteveOSteveO Member Posts: 164
    You could just not declare an Interface and then make your ClassInterfaceType AutoDual. This works in the projects I have played around with.

    You could also just leave it the way it is, take a look at a few other automation servers eg. NEP Queue Handler, Navision Communication Component version 2, Microsoft Outlook 11.0 Object Library

    You'll see duplicate methods like Application, _Application, MessageQueueListener, IMessageQueueListener

    I personally wouldn't worry too much about it as it seems to be a common occurrence.
    This isn't a signature, I type this at the bottom of every message
  • elwin68elwin68 Member Posts: 153
    Thanks for the answer.

    It works, but it will be recommended not to use.

    I leave it as it is.
Sign In or Register to comment.