Click here to Skip to main content
14,267,154 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have been working on some audio programs using DirectX. I have been developing them on XP and was surprised to find that the programs would not run under Win7 X64. I have the DirectX SDK June 2010 installed on both OS's. In order to isolate the problem I created this simple piece of code.

namespace Win7AudioTest
    public partial class Form1 : Form
        // This code compiles and runs under XP with Vis2008
        // it compiles under Win7 with Vis2008 (Build Succeeded)
        // but will not run unless the next line is commented out.

        public Audio _audio = null;

        public Form1()

Any suggestions would be appreciated.
Yanick Salzmann 9-Apr-11 11:43am
How does the "will not run" manifest itself? Do you get an exception? Isnt it doing anything or whats the problem?
electriac 9-Apr-11 11:49am
I get the window Win7AudioTest has stopped working
Yanick Salzmann 9-Apr-11 11:54am
And what is the debugger telling if you are starting it in debug mode? And if you open the More details view in the "has stopped working"-window does it show you an exception type?
electriac 9-Apr-11 11:59am
I get error 2652
electriac 9-Apr-11 12:19pm
This is the compiler debug inf:

System.BadImageFormatException was unhandled
Message=" is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)"
at Win7AudioTest.Form1..ctor()
at Win7AudioTest.Program.Main() in G:\SourceCode\2008\Media Progs\DX9 Development\Win7AudioTest\Win7AudioTest\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Yanick Salzmann 9-Apr-11 12:27pm
Is the XP system a 32 Bit operating system?
electriac 9-Apr-11 12:29pm
XP is 32bit and no problem. Win7 is 64bit.
Yanick Salzmann 9-Apr-11 12:36pm
Yes, i didnt see the x64 in my first few comments but see the "solution", x64 isnt supported by Micrisoft.DirectX... (and never will be), XNA maybe will support it later.
electriac 9-Apr-11 12:40pm
Yet another reason to stay with XP. The list gets longer every day.
Yanick Salzmann 9-Apr-11 12:44pm
Isnt a problem, just make sure your application is run as a 32 Bit executable. I run XNA on my 64 Bit Win7 without any problems.
electriac 9-Apr-11 12:47pm
How do I run it as 32bit. Sorry for the stupid question but could not find that alternative.
Yanick Salzmann 9-Apr-11 12:57pm
In your project settings change "Any CPU" or "x64" to "x86" so that its only for x86.
Rate this:
Please Sign up or sign in to vote.

Solution 1

I guess you are using managed DirectX (Microsoft.DirectX namespaces). Its no longer supported by microsoft and doesnt work with x64 (neither does XNA). If you want to use managed DirectX in x64 you may think about SlimDX.
Rate this:
Please Sign up or sign in to vote.

Solution 2

Yanick and Luc Pattyn

Many thanks between you folks you have solved my problem. I had never noticed the CPU setting before. I recompiled 32bit and problem was solved.

Many Thanks
Luc Pattyn 10-Apr-11 4:52am
you're welcome. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100