Tips and Tricks Using Managed Code

This topic discusses the basics of how to install and use Microsoft DirectX 9.0 for Managed Code and documentation. The following sections are included.

  • Getting Started with DirectX 9.0 for Managed Code
  • Using Sample Applications
  • Class Inheritance
  • Debugging DirectX Applications
  • Using Managed DirectX Documentation in Visual Studio .NET 2003
  • Using DirectX Help Documentation
  • DirectX Redistribution

Getting Started with DirectX 9.0 for Managed Code

Install the latest Microsoft .NET Framework runtime from How to Get the .NET Framework Leave Site. This installs the Framework on your local computer, which includes the .NET runtime. The .NET runtime is a set of dynamic-link libraries (DLLs) that managed code applications require. You can install the full software development kit (SDK), but only the runtime is required.

Download the DirectX 9.0 SDK from the DirectX Leave Site Web site, or from MSDN DirectX Downloads Leave Site. The SDK includes the set of DirectX DLLs that are required to run DirectX applications.

Note: Uninstall previous versions of DirectX before installing this release. Use the Add or Remove Programs Control Panel to remove an earlier version. Before they run, applications developed for managed code should confirm that DirectX 9.0 has been installed.

Using Sample Applications

Pre-tested code for sample applications can be found at:
(SDK root)\Samples\Managed\

The sample applications should be built with Microsoft Visual Studio .NET 2003.

For each DirectX technology you will find the following folder structure.

  • Individual sample folders: Contain a variety of applications specifically designed for managed code. Within each subfolder you will find a complete Visual Studio .NET 2003 project and solution that will quickly get you started.
  • Bin subfolder: Contains compiled applications that you can run by double-clicking.
  • Tutorials subfolder (Microsoft Direct3D only): Contains sample applications that will take you step-by-step through the procedures of creating a complete working application. The Direct3D C# tutorials are described in detail in Direct3D Tutorials.

Class Inheritance

DirectX 9.0 for Managed Code does not support class inheritance in applications. Inheriting from DirectX 9.0 for Managed Code classes is not recommended and the resulting behavior is undefined.

Although you may discover that certain inherited classes work with this version of DirectX 9.0 for Managed Code, such inheritance may not work in future versions.

Debugging DirectX Applications

From the Visual Studio .NET 2003 Integrated Development Environment (IDE):

  • Within the Solution Explorer pane, right-click your project (not the solution) and select Properties.
  • Click the Configuration Properties folder at the left, then click the Debugging selection.
  • Within the Debuggers options, set Enable Unmanaged Debugging to True. It is set to False by default.

Using Managed DirectX Documentation in Visual Studio .NET 2003

When the SDK has been loaded using the above procedure, documentation will be readable from within Visual Studio .NET 2003. From the Visual Studio Help menu, select Contents to open a table of contents, Index to search by alphabetical words, or Search to do a text search in the documentation, as shown in the following.

Visual Studio screen shot with help menu

From within managed code, you can also view detailed documentation and syntax by clicking anywhere on the name of a class, structure, member, property, or field and then pressing F1.

Using DirectX Help Documentation

Installing DirectX documentation from both the DirectX SDK and MSDN Library can result in duplicate topics in Visual Studio .NET 2003. If this occurs, take the following steps to uninstall the DirectX documentation from the SDK.

  1. In Control Panel, click the Add/Remove Programs icon.
  2. Highlight Microsoft DirectX 9.0 SDK and then click Change.
  3. When the InstallShield Wizard opens, click Next.
  4. Select Modify. Click Next.
  5. In the DirectX Documentation list, click This feature will not be available.
  6. Click Next and the documentation will be removed.

DirectX Redistribution

Stand-alone developer runtime installers install only the DirectX developer and debug runtime for redistribution purposes. These installers are located at:
(SDK root)\Developer Runtime\Managed DirectX\

DirectX 9.0 for Managed Code includes a full set of DLLs for redistribution. To install the full set, perform the following steps.

  1. Verify that the Framework is installed.
  2. Navigate to:
    (SDK root)\Redist\DirectX9\
  3. Call DXSetup.exe with the /InstallManagedDX command line attribute, as follows.
DXSetup.exe /InstallManagedDX