After my previous post on how to write a
.NET control (.NET DLL) to extend Microsoft Navision's functionality, I've
received some feedbacks that signalled me a little strange behaviour: when you
import your new .NET DLL for using it in Navision, on the C/AL Symbol menu (when
you reference the control) you can see all the default COM
methods and properties (Equals,
GetHashCode,GetType,ToString etc.). This is not so good, I know...
How to solve this?
The key for not exposing all the standard COM methods
and properties is to use the DispIdAttribute class, that permits to
specify the COM dispatch identifier (DISPID) of a
method, field, or property.
You have to modify the source code in my previous post
as follow:
1 Imports System.Runtime.InteropServices
2 Imports System.Reflection
3
4 <Assembly: AssemblyKeyFileAttribute("sgKey.snk")>
5
6 Public Interface INavControl
7 <DispId(1)> _
8 Function SaySomething() As String
9 End Interface
10
11 <ClassInterface(ClassInterfaceType.None)> _
12 Public Class NavisionControl
13 Implements INavControl
14 Public Function SaySomething() As String Implements INavControl.SaySomething
15 Return "Hi, I'm the .NET Control and this comes from my function"
16 End Function
17 End Class
and then rebuild the project and register again the
control:

After the registration, open your Navision form
previously created (exactly like explained on my previous post) and place a
reference to the newly created control:

Now, check the exposed methods of this new
control:

As you can see, the .NET control expose only the
declared method (SaySomething).
More elegant now... 