locked
DirectX Error

    Question

  • I am making a game called Battle Tank and I referenced a DirectX reference just as the tutorial said but I'm getting an error saying:

    1 Error, The type 'Microsoft.DirectX.Direct3D.Device' exists in both 'c:\WINDOWS\Microsoft.NET\DirectX for Managed Code\2.0.0.0_x86\Microsoft.DirectX.dll' and 'c:\WINDOWS\Microsoft.NET\DirectX for Managed Code\1.0.2902.0\Microsoft.DirectX.Direct3D.dll'

    Here's my code to the game:

    using System;

    using System.Collections.Generic;

    using System.ComponentModel;

    using System.Data;

    using System.Drawing;

    using System.Text;

    using System.Windows.Forms;

    using Microsoft.Samples.DirectX.UtilityToolkit;

    namespace BattleTank2005

    {

    public partial class GameEngine : Form {

    protected override void OnPaint(PaintEventArgs e) {

    deltaTime = FrameworkTimer.GetElapsedTime();

    FrameworkTimer.Start();

    device.Clear(ClearFlags.Target, Color.DarkBlue, 1.0f, 0);

    device.Present();

    this.Invalidate();

    }

    public GameEngine()

    {

    InitializeComponent();

    this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);

    // Get the ordinal for the default adapter

    int adapterOrdinal = Manager.Adapters.Default.Adapter;

     

     

    // Get our device capabilities so we can check them to set up the CreateFlags

    Caps caps = Manager.GetDeviceCaps(adapterOrdinal, DeviceType.Hardware);

    CreateFlags createFlags;

    // Check the capabilities of the graphcis card is capable of

    // performing the vertex-processing operations

    // The HardwareVertexProcessing choice is the best

    if (caps.DeviceCaps.SupportsHardwareTransformAndLight)

    {

    createFlags = CreateFlags.HardwareVertexProcessing;

    }

    else

    {

    createFlags = CreateFlags.SoftwareVertexProcessing;

    }

    // If the graphics card supports vertex processing check if the device can

    // do rasterization, matrix transformations, and lighting and shading operations

    // This combination provides the fastest game experience

    if (caps.DeviceCaps.SupportsPureDevice && createFlags == CreateFlags.HardwareVertexProcessing)

    {

    createFlags |= CreateFlags.PureDevice;

    }

    // Set up the PresentParameters which determine how the device behaves

    PresentParameters presentParams = new PresentParameters();

    presentParams.SwapEffect = SwapEffect.Discard;

    // Make sure we are in windowed mode when we are debugging

    #if DEBUG

    presentParams.Windowed = true;

    #endif

    // Now create the device

    device = new Device(

    adapterOrdinal,

    DeviceType.Hardware,

    this,

    createFlags,

    presentParams

    );

    }

    private double deltaTime;

    private Microsoft.DirectX.Direct3D.Device device;

    }

    }

    Saturday, April 29, 2006 11:13 PM

Answers

  • Hi,
    that means you're referencing both versions of the .Net framework in your project. You have to go to the references and leave all assembly references from the version you don't want to use. For example, if you want to use the .net 2.0 then remove all assemblies you're referencing from the .net v1.1.
    Sunday, April 30, 2006 2:07 AM
  • http://www.thezbuffer.com/articles/385.aspx

    There will never be a Direct3dX for MDX 2.0 they put all the namespaces inside a single assembly. You only need DirectX.dll

    Monday, May 01, 2006 8:50 AM

All replies

  • Hi,
    that means you're referencing both versions of the .Net framework in your project. You have to go to the references and leave all assembly references from the version you don't want to use. For example, if you want to use the .net 2.0 then remove all assemblies you're referencing from the .net v1.1.
    Sunday, April 30, 2006 2:07 AM
  • I know what it means but it won't let me, here I'll tell you exactly what i'm referencing:

    1. Microsoft.DirectX

         Version: 2.0.0.0

         Runtime Version: 2.0.50727

    2. Microsoft.DirectX.Direct3D

         Version: 1.0.2902

         Runtime Version: 1.1.4322

     

    I realize that they are two different versions but Microsoft has not yet released a Microsoft.DirectX.Direct3D version 2.0 yet, so that is why I had to reference two different versions, so I don't know what it wants me to do to fix it yet.

    Sunday, April 30, 2006 7:16 PM
  • So, remove the reference from the v2.0 and include its predecessor.
    Monday, May 01, 2006 12:14 AM
  • http://www.thezbuffer.com/articles/385.aspx

    There will never be a Direct3dX for MDX 2.0 they put all the namespaces inside a single assembly. You only need DirectX.dll

    Monday, May 01, 2006 8:50 AM