Need help with C# COM Interop, creating a DCOM server



I am in desperate need to get help in answering some questions in
regards to building a DCOM Server using C#.

I need to create a DCOM server using C#.NET, I realise that you first
need to create the managed code, attach interfaces and use the CCW
command line tool to add a COM wrapper to the assembly.

The server will be communicating with a DCOM client which I didn't
write, but I have all the documentation on what interfaces and methods
it uses.

Please keep in mind I have never written a COM object before.

The questions I have are as follows:

1. What extra do I need to do to make the COM object into a DCOM object?

2. Do I need to worry about IInterface or IDispatch? Or is this all
done by the CCW Wrapper?

3. How do I generate the GUID for each interface? And do I need to
worry about the QueryInterface Interface which the client uses to find
out which interfaces are available?

4. I found a basic COM Interop Server in C#, which just returns the
name of a person to the COM client as shown below. My guess is that I
just create the interfaces on the Server side COM object as the
documentation requests and then write my own code inside?

A DCOM Client and Server example would also be great if anyone has one
written in .NET (Any language would be fine, but prefer C# or VB.NET)


using System;
using System.Runtime.InteropServices;
namespace CSharpServer
// Since the .NET Framework interface and coclass have to behave as
// COM objects, we have to give them guids.
[Guid("DBE0E8C4-1C61-41f3-B6­ A4-4E2F353D3D05"
public interface IManagedInterface
int PrintHi(string name);

[Guid("C6659361-1625-4746-93­ 1C-36014B146679"
public class InterfaceImplementation : IManagedInterface
public int PrintHi(string name)
Console.WriteLine("Hello, {0}!", name);
return 33;


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