Urgent help needed - Direct3D problem !!!

Started by
9 comments, last by apocalypse_k40 18 years ago
I am just a beginner in directX programming so I began trying some tutorials... But when I wrote just my first example and run I get a strange FileNotFoundException... Here is the snippet where I got the error : static void Main() { using ( Form1 form = new Form1() ) { if ( !form.InitializeGraphics() ) //-----> FileNotFoundException { MessageBox.Show( "Unable to initialize DirectX." ); form.Dispose(); return; } Application.Idle += new EventHandler( form.OnApplicationIdle ); Application.Run( form ); } } and the InitializeGraphics() method is an method of partial class Form1: ... ... public bool InitializeGraphics() { PresentParameters pp = new PresentParameters(); pp.SwapEffect = SwapEffect.Discard; try { m_device = new Device(0, DeviceType.Hardware, this.Handle, CreateFlags.SoftwareVertexProcessing, pp); return true; } catch (DirectXException) { return false; } } ... ... The exact exception detail is : System.IO.FileNotFoundException was unhandled Message="The specified module could not be found. (Exception from HRESULT: 0x8007007E)" Source="DX3D_init" StackTrace: at DX3D_init.Form1.InitializeGraphics() at DX3D_init.Program.Main() in C:\DirectxWork\DX3D_init\DX3D_init\Program.cs:line 17 at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() So as I said I am just a beginner google doesn't help too :S ... Please help me ! What is the problem ? Thnx...
Advertisement
I don't know about MDX or whatever that is, but don't you need to create a D3D interface before you create the D3D Device?
You should probably check whether you have specified enough information to be able to create the device.
The parameters that I specify on a minimum usually involves the following
presentParams = new PresentParameters();presentParams.BackBufferCount = 1; //Number of backbuffers to createpresentParams.BackBufferFormat = adapterInfo.CurrentDisplayMode.Format; //The current format of the display devicepresentParams.BackBufferWidth = control.Width;presentParams.BackBufferHeight = control.Height;presentParams.SwapEffect = SwapEffect.Discard; //How the backbuffer and the current display will be swapped


Also take a look at the beginner tutorials on MDXInfo.com and see if they work. You might have some weird assembly problem.

I hope this helps.
Take care.
nope it doesn't help either :( ... but thanx for giving a try :D ...

maybe it's something about my native class ?

using System;
using System.Runtime.InteropServices;

namespace DX3D_init
{
public class NativeMethods
{
[StructLayout(LayoutKind.Sequential)]
public struct Message
{
public IntPtr hWnd;
public uint message;
public IntPtr wParam;
public IntPtr lParam;
public uint time;
public System.Drawing.Point p;
}

[System.Security.SuppressUnmanagedCodeSecurityAttribute]
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern bool PeekMessage(out Message msg, IntPtr hWnd, uint messageFilterMin, uint messageFilterMax, uint flags );
}
}
What version of the DXSDK do you have and are you using the Managed DirectX for .NET 2.0? This was a common problem with the October 2005 DXSDK.
I used to use the October 2005 SDK with .NET 2.0 but while I found out that this release has such problems I uninstalled it and install the February 2006 SDK but still have the same problem...
Maybe I haven't uninstalled October 200 SDK properly (I simply uninstalled it from the add/remove)? Because strangely when I open the "add references" window in my project I see 3 versions of DirectX which two of them were installed with October 2005...
Quote:Original post by apocalypse_k40
Maybe I haven't uninstalled October 200 SDK properly (I simply uninstalled it from the add/remove)? Because strangely when I open the "add references" window in my project I see 3 versions of DirectX which two of them were installed with October 2005...
That's probably A Bad Thing. Using the Add/Remove Programs control pannel is the correct way to remove it, but it seems that you've managed to install it 3 times. I'd have a look around your hard drive for any old versions of the SDK. Also have a look at your Visual Studio directories to check that it's not picking up an old version of the SDK.
Quote:Original post by Evil Steve
Quote:Original post by apocalypse_k40
Maybe I haven't uninstalled October 200 SDK properly (I simply uninstalled it from the add/remove)? Because strangely when I open the "add references" window in my project I see 3 versions of DirectX which two of them were installed with October 2005...
That's probably A Bad Thing. Using the Add/Remove Programs control pannel is the correct way to remove it, but it seems that you've managed to install it 3 times. I'd have a look around your hard drive for any old versions of the SDK. Also have a look at your Visual Studio directories to check that it's not picking up an old version of the SDK.


No I don't think the problem is that...

I just tried to something at the first line of my InitializeGraphics() method (like a endless while loop) but no it even doesn't come at that line and again says that form.InitializeGraphics() ---> FileNotFoundException :(
I tried to initialize the m_device to null when I first declare it (at the beginning of Form1 class) and again strangely the FileNotFounException moves to the line when I creat the Form1 instance form...

So I think there is something wrong with initializing m_device..

Still awaiting further assistance :P ...

Thanx
Check your references very carefully and make sure you have referenced the latest versions of the DX assemblies.

This topic is closed to new replies.

Advertisement