This sample demonstrates using a C# server with a C++ COM client.
Note |
---|
You must run Visual Studio as an administrator 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
If you are running Windows Vista, right-click the Visual Studio 2008 shortcut on the Start Menu and choose Run as administrator when loading the development environment.
-
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
If you are running Windows Vista, right-click the Command Prompt shortcut on the Start Menu and choose Run as administrator when loading the command prompt.
-
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