DLL Communication Interface: .NET class library <-> Win32-DLL




I need to an TCP/IP Interface for communication with an embedded
Since I have two different design ideas in mind, I am wondering
you could give me some hints to decide:

- Interface should be used for company internal purposes/software but
as an interface for our customers -> interface should be a DLL
- internally, the interface should only be used with C# Applications
- our customers want to use the interface with "native" C++, VB6, VBS,
C#, VB.NET, Labview, ...

Design 1:
- implement the interface as .NET class library in C#
- expose this .NET class library as COM dll
(whatever this means exactly...) so that it can be used by
C++, VB6, VBS, ...
- advantage: easy implementation of the interface in C#;
easy debugging
- disadvantage/open issue: what does it mean to expose the
interface as COM dll (esp. in terms of effort); does
exposing as COM dll really provide an interface for all
possible applications? how can this COM interface be used?

Design 2:
- implement the interface in C++ as standard Win32-dll
- provide a C# wrapper class (maybe compiled as .net class library)
mainly for internal purposes
- advantage: well-known win32-dll-interface -> our customers
know how to use it and there are no tradeoffs
- disadvantage: complex socket programming in C++ required;
C# wrapper required; more complex software debugging

Which design would you prefer? Why? Could you give
me some decision guidance, please?!



Nicholas Paldino [.NET/C# MVP]

Personally, I would go with creating a COM component. You ^could^ do
the development in .NET and expose the item as a COM component, but for some
reason, it seems like it might almost be easier to do using Active Template
Library (ATL) as it has a number of classes that wrap Socket functionality.

If you have a majority of customers that are going to use the unmanaged
component, then I would recommend developing it using C++, as it should make
distribution easier. If you do the development in .NET and then expose it
as a COM object, you will have to distribute the framework, and that might
create a distribution scenario which is harder than you are looking for.

Hope this helps.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question