Export (0) Print
Expand All

COM Interop Part 2 Sample

This sample demonstrates using a C# server with a C++ COM client.

This sample contains the source code for the COM Interop Part 2: C# Server Tutorial.

Note   Visual C++ must be installed to compile this sample.

Building and Running the Sample Within Visual Studio

To build and run the COM Interop Part 2 sample

  1. Open the solution (CSharpServerWithCOMClient.sln).
  2. In Solution Explorer, right-click the COMClient project and click Properties.
  3. Open the Configuration Properties folder and click Debugging.
  4. In the Command Line Arguments property, enter a name.
  5. Click OK.
  6. From the Debug menu, click Start Without Debugging.

Building and Running the Sample from the Command Line

To build and run the COM Interop Part 2 sample

  1. Use the Change Directory command to change to the COMInteropPart2\COMClient directory.
  2. Copy the C# server code into the COMClient directory:
    copy ..\CSharpServer\CSharpServer.cs
    
  3. Compile the server:
    csc /target:library CSharpServer.cs
    regasm CSharpServer.dll /tlb:CSharpServer.tlb
    
  4. Compile the client (make sure the path and environment variables are set properly with vcvars32.bat):
    cl COMClient.cpp
    
  5. Run the client:
    COMClient friend
    

See Also

COM Interop Part 2: C# Server Tutorial | Tutorial Samples

Show:
© 2014 Microsoft