This sample demonstrates using a C# server with a C++ COM client.
| Note |
|---|
You must have administrator rights to run this program and Visual C++ must be installed to compile this sample. |
| Security Note |
|---|
This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended. |
To build and run the COM Interop Part 2 sample within Visual Studio
In Solution Explorer, right-click the COMClient project and click Properties.
Open the Configuration Properties folder, and click Debug.
In the Command Line Arguments property, enter a name.
Click OK.
From the Debug menu, click Start Without Debugging.
To build and run the COM Interop Part 2 sample from the Command Line
Use the Change Directory command to change to the COMInteropPart2\COMClient directory.
Copy the C# server code into the COMClient directory:
copy ..\CSharpServer\CSharpServer.cs
Compile the server:
csc /target:library CSharpServer.cs regasm CSharpServer.dll /tlb:CSharpServer.tlb
Compile the client (make sure the path and environment variables are set properly with vcvars32.bat):
cl COMClient.cpp
Run the client:
COMClient friend