# [.net] Using DirectX9

This topic is 5038 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi everyone ! I wanted to start using DirectX with C#, but I've got a (major) problem. In the tutorial, they say to use the following code:
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
The problem is that my compiler doesn't recognize neither DirectX nor Direct3D. I downloaded the DirectX SDK while I was programming in C++ but now I am going toward C# so it must not be the problem... unless there is a DirectX SDK for C# too... which would be a real pain since I'm on 56kbps and these downloads are something like 50Mo+ ... is there something really stupid I didn't see yet ? I used the following code:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;

namespace DirectX_Tutorial
{
public class WinForm : System.Windows.Forms.Form
{
private Device device;
private System.ComponentModel.Container components = null;

public WinForm()
{
InitializeComponent();
}

protected override void Dispose (bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}

private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.Size = new System.Drawing.Size(500,500);
this.Text = "DirectX Tutorial";
}

static void Main()
{
using (WinForm our_dx_form = new WinForm())
{
Application.Run(our_dx_form);
}
}
}
}



##### Share on other sites
MS bundles the managed and unmanaged version of the SDK into 1 package. If you have indeed downloaded the latest SDK, just be sure you made references to the DX libraries in your C# projects.

##### Share on other sites
How would I do that ? I referenced the libraries through Tools=>Options=>Projects in MSV... I even referenced a lot more folders than I should have but I thought it would fix my problem but it didn't. What exact folder would I have to link ?

[Edited by - White Scorpion on January 1, 2005 12:33:20 AM]

##### Share on other sites
I'm using the C# Express but I know adding references in other IDE's are straightforward. There's no need to use the Tools menu. I do the following
1) Open a project
2) On the Solution Explorer, right click the "Reference" node, then click "Add Reference",
3) Find the DirectX assemblies under the .NET tab.
4) click OK

That would be all. You should see new nodes under the "Reference" besides the default System, System.Windows.Forms, System.Drawing

If you can't see any DX assemblies, then you don't have the managed version of DX. Be sure to download the latest SDK. It's big file though :(

##### Share on other sites
::I even referenced a lot more folders than I should have

In C# you do not reference FOLDERS, but DLL's. Assemblies. Directly.

And you do not do yo through the fancy dialog you did, but through the references node IN the project. Just look at the project in the Solutions explorer. There is a node "references". THere you can add additional references.

And while you search, please at least have ONE look at the documentation. Helps to find your way around the IDE without making too stupid mistakes.

##### Share on other sites
Thank you guys, it worked perfectly. Will I have to add them to every project or it will stay ?

##### Share on other sites
you have to add them on every project

avoid using wizard or DX project templates if you're just starting to program directx, so this means you have to manually load the reference

enjoy!!!

1. 1
2. 2
Rutin
25
3. 3
4. 4
5. 5

• 10
• 10
• 13
• 20
• 14
• ### Forum Statistics

• Total Topics
632949
• Total Posts
3009367
• ### Who's Online (See full list)

There are no registered users currently online

×