Beginning Managed DirectX (C#): Manager.Adapters.Default

I just installed the December 2005 DirectX SDK, and am using Visual Studio 2005.

I have a reference to C:\WINDOWS\Microsoft.NET\DirectX for Managed Code\2.0.0.0_x86\Microsoft.DirectX.dll in my project.

The problem:

I've seen numerous tutorials doing this:

int adapterOrdinal = Manager.Adapters.Default.Adapter;

Which results in this compile error:

Static member 'Microsoft.DirectX.Direct3D.AdapterCollection.Default.get' cannot be accessed with an instance reference; qualify it with a type name instead

First, when I type in Manager.Adapters. Intellisense does not show a Default property.

When I go to the definition of AdapterCollection (returned by the Adapters property), I do see the static Default property:

public struct AdapterCollection : IEnumerable<AdapterDetails> {
   public const int DefaultOrdinal = 0;

   public static bool operator!=(AdapterCollection l, AdapterCollection r);
   public static bool operator==(AdapterCollection l, AdapterCollection r);

   public int Count {
      get;
   }
   public static AdapterDetails Default {
      get;
   }
...

Furthermore, AdapterDetails.Adapter does exist and should return an int:

public struct AdapterDetails {

   public static bool operator!=(AdapterDetails l, AdapterDetails r);
   public static bool operator==(AdapterDetails l, AdapterDetails r);

   public int Adapter {
      get;
   }
...

First off, shouldn't that public int Adapter property actually be coded as public static int Adapter

What am I doing wrong   Any hints would be greatly appreciated!



Answer this question

Beginning Managed DirectX (C#): Manager.Adapters.Default

  • popsdawg

    Thanks for taking the time to answer some really basic questions, I appreciate it.  I dabbled in DirectX under C++ many years ago--this is a steep learning curve for me, but fun nonetheless!

  • luvly_girl

    Ok, thanks for the information (don't suppose there's an ETA for .NET 2.0 being release to production ).

    A quick question to show my newness:  If I use the 1.1 version, but am coding in .NET 2.0, will I have 2 instances of the .NET runtime in memory, both the 2.0 (for my code) and the 1.1 (for the MDX)


  • Toper

    No, you will not have 2 instance of the .NET runtime in memory (in fact it's not even possible to have 2 different version of .NET loaded into the same process). Your process will use .NET 2.0 runtime and it will simply load the MDX 1.1 assemblies because it's backward compatible.
  • kalle vanska

    You are using the MDX assembly for .NET 2.0 which is a bit different that the MDX for .NET 1.1. Most of the sample I saw are coded for MDX for .NET 1.1 so that's why you get an error when you try to use Manager.Adapters.Default.Adapter. In the 2.0 version the equivalent is simply AdapterCollection.Default. Maybe you should stick to the 1.1 version (which works finde with .NET 2.0 and VS2005) since the current 2.0 version is just a beta version.
  • Beginning Managed DirectX (C#): Manager.Adapters.Default