468,315 Members | 1,442 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,315 developers. It's quick & easy.

COM Interop -- check my code please

Hello,

after a lot of readings I've got something working. Can you please check --
is it enough? .Net server and COM-client, also I generated key file and
place "ref" to it in AssemblyInfo.vb this way:

<Assembly: AssemblyKeyFile("..\..\keyfile.snk")>

The code:

Namespace NSClientSource

<ComVisible(False)Public Delegate Sub DisconnectDelegate()

<GuidAttribute("4CD0B63A-5A3E-48d1-9E92-5C58B04909F1"), _
InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIDispatch)_
Public Interface ISClientEvents
Sub Disconnect()
End Interface

<GuidAttribute("F597E3DB-1BEB-4d41-8C3F-1CAA0AA6F659"), _
InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIDispatch)_
Public Interface ISClientMembers
Property Port() As Integer
Property Host() As String
End Interface

<ComSourceInterfaces(GetType(ISClientEvents)), _
ComDefaultInterface(GetType(ISClientMembers)), _
Guid("3964C432-8412-4c73-A04D-86D7C57D694E")_
Public Class SClient
Implements ISClientMembers
Public Event Disconnect As DisconnectDelegate

Public Enum EFaultReason
eFaultUnknown = 0
eFaultWrongLength = 1
...
End Enum

....


After all this I can use one (but not all) object in VB(A) application.
All members and events are "visible", exept that enum members are shown in a
bit strange way:

EFaultReason_eFaultUnknown
EFaultReason_eFaultWrongLength

and so on -- with prefix, is it OK, or there's a way to make it shown
without prefix?

The third one in my project is a Control -- is it possible to use it also?
Like ActiveX controls in old times?

Although it's visible in COM object browser (F2 in MSA) but there's no way
to place control in a form and use it. What should I read?

Without <ComVisible(False)DisconnectDelegate sub also shown in COM
client -- but I don't need it?

Thank you.

--
best regards!

Jul 11 '06 #1
1 884
Serge,
>All members and events are "visible", exept that enum members are shown in a
bit strange way:

EFaultReason_eFaultUnknown
EFaultReason_eFaultWrongLength

and so on -- with prefix, is it OK, or there's a way to make it shown
without prefix?
Yes it's ok, and there's not much you can do about it.

>The third one in my project is a Control -- is it possible to use it also?
Like ActiveX controls in old times?
No, hosting Windows Forms controls as ActiveX controls is generally
not supported (with a few exceptions).

>Without <ComVisible(False)DisconnectDelegate sub also shown in COM
client -- but I don't need it?
You don't have to expose the delegate class if that's what your
asking.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 11 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Sudha | last post: by
7 posts views Thread by R Reyes | last post: by
5 posts views Thread by Dave | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.