Developing DSF Applications in Managed Code

There are several ways to develop a DSF test application in managed code that interfaces the DSF COM objects. For your managed code to communicate with COM objects, you must import the COM types into a COM class wrapper.

You can use any of the following methods to create a COM class wrapper:

  • Create the COM Class Wrapper Yourself through the Type Library Importer.

    The Type Library Importer (Tlbimp.exe) converts the type definitions found in a COM type library (.tlb) file into equivalent definitions in a common language runtime assembly. The output of Tlbimp.exe is a binary file (known as an assembly) that contains runtime metadata for the types that are defined within the original type library. For more information, see Type Library Importer.

    When you create your own custom simulations in unmanaged COM code, you may have to import those types yourself to create managed applications for testing custom simulations. For example, this method can generate the wrappers for the keyboard, audio, and generic HID simulators. For more information, see Com Interop Tutorials.

    The standard DSF .tlb files are available in the Windows Driver Kit (WDK).

    Note   The SoftEhchIF.tlb library is not available in the current release of the WDK. You must use one of the other methods described in this topic to reference this library.

  • Reference Pre-Generated COM Class Wrappers.

    These wrappers are a part of the Managed Interop Assemblies package that is installed through the DSF installation. To install this package, follow these steps:

    1. Copy the DSF installation package (DSFx86Runtime.msi or DSFx64Runtime.msi) from the WDK media to the computer where you intend to build your test applications. This computer is referred to as the build computer**.**
    2. Depending on the CPU platform of the build computer, run the DSF installation package by double-clicking DSFx86Runtime.msi or DSFx64Runtime.msi.
    3. Read and accept the EULA.
    4. Expand the drop-down menu for Device Simulation Framework and select Entire feature will be unavailable.
    5. Click Next and then click Install to install the pre-generated COM class wrappers. This also installs the DSF Managed Interop Assemblies into the global assembly cache (GAC).

    Note  To avoid conflicts, you must only install the Managed Interop Assemblies package in the build computer. If the Device Simulation Framework has been previously installed, you must uninstall it from the build computer.

    Note   Pre-generated COM class wrappers are only available for the SoftEHCI, SoftUSB, DSF, and SoftUSBLoopback COM objects. You must use one of the other methods described in this topic to reference other DSF objects or libraries.

    In order to reference the DSF Managed Interop Assemblies that were installed in the GAC, you must copy these assemblies to the Public Assemblies folder before you can access them through the**.NET References** tab in Visual Studio. For more information, see How to: Add or Remove References in Visual Studio.

  • Use Visual Studio and the Runtime Callable Wrapper to Generate COM Class Wrappers.

    The Common Language Runtime component of the .Net framework exposes COM objects through a proxy called the runtime callable wrapper (RCW). Although the RCW appears to be an ordinary object to .NET clients, its primary function is to marshal calls between a .NET client and a COM object.

    You can to add a reference to the runtime DSF COM objects and generate the COM class wrappers by using the RCW. For more information, see Runtime Callable Wrapper.

    In order to use RCW, you must install the DSF COM objects in the computer that you use to build your test applications. To install only the DSF COM objects, follow these steps:

    1. Copy the DSF installation package (DSFx86Runtime.msi or DSFx64Runtime.msi) from the WDK media to the build computer**.**
    2. Depending on the CPU platforms of the build computer, run the DSF installation package by double-clicking DSFx86Runtime.msi or DSFx64Runtime.msi.
    3. Read and accept the EULA.
    4. Expand the drop-down menu for Managed Interop Assemblies and select Entire feature will be unavailable.
    5. Click Next and then click Install to install the DSF COM objects.

    Note   To avoid conflicts, you must only install the DSF COM objects in the build computer. If the Managed Interop Assemblies package has been previously installed, you must uninstall it from the build computer.

    If you use this method, you should be aware of the following points:

    • The SoftHIDUSBK and SoftHID COM objects are not available but the DSF and SoftUSB COM objects are available.
    • This method only works in 32-bit environments. For more information about how to develop DSF applications in 64-bit environments, see Using Visual Studio to Develop 64-Bit DSF Applications.

 

 

Send comments about this topic to Microsoft

Build date: 9/21/2010