Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

COM Interop Part 1 Sample

This sample demonstrates how a C# program can interoperate with an unmanaged COM component.

This sample contains the source code for the COM Interop Part 1: C# Client Tutorial.

Building and Running the Sample Within Visual Studio

To build and run the COM Interop Part 1 samples

  1. Open the solution (COMInteropPart1.sln).
  2. In Solution Explorer, right-click the Interop1 project and click Set as StartUp Project.
  3. In Solution Explorer, right-click the Interop1 project and click Properties.
  4. Open the Configuration Properties folder and click Debugging.
  5. In the Command-Line Arguments property, enter an AVI file such as c:\winnt\clock.avi.
  6. Click OK.
  7. From the Debug menu, click Start Without Debugging.
  8. Repeat the preceding steps for Interop2.

If the QuartzTypeLib.dll included with Interop1 is out of date

  1. In Solution Explorer, open References for Interop1.
  2. Right-click QuartzTypeLib and click Remove.
  3. Right-click References and click Add Reference.
  4. In the COM tab, select the component named "ActiveMovie control type library."
  5. Click Select and OK.
  6. Rebuild Interop1.
Note   Adding a reference to the component does the same thing as invoking tlbimp at the command line to create QuartzTypeLib.dll (as shown below).

Building and Running the Sample from the Command Line

To build and run the COM Interop Part 1 samples

  1. Use the Change Directory command to change to the Interop1 directory.
  2. Type the following:
    tlbimp %windir%\system32\quartz.dll /out:QuartzTypeLib.dll
    csc /r:QuartzTypeLib.dll interop1.cs
    interop1 %windir%\clock.avi
    
  3. Use the Change Directory command to change to the Interop2 directory.
  4. Type the following:
    csc interop2.cs
    interop2 %windir%\clock.avi
    

See Also

COM Interop Part 1: C# Client Tutorial | Tutorial Samples

Show:
© 2015 Microsoft