BadImageFormatException

Dec 9, 2009 at 6:21 AM

I keep getting a "Could not load file or assembly 'Naudio..." every time I try to run a sample project. What am I doing wrong? I checked the reference in Visual Studio and verified the dll is in the output directory.

Coordinator
Dec 11, 2009 at 4:44 PM

that's strange. what's the stack trace of the exception?

any details on your environment - version of VS, Windows etc?

Dec 15, 2009 at 5:34 AM

Basically, it's the first time it uses a class from the dll:

{"Could not load file or assembly 'NAudio, Version=1.3.8.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format."}

at NAudioWpfDemo.AudioGraph..ctor()
   at NAudioWpfDemo.ControlPanelViewModel..ctor(IWaveFormRenderer waveFormRenderer, SpectrumAnalyser analyzer) in C:\Users\Kevin\Desktop\NAudio-1-3\Source Code\NAudioWpfDemo\ControlPanelViewModel.cs:line 23

VS2008 Win7

Dec 15, 2009 at 9:58 AM

You normally see that kind of thing when using 64bit windows.

SNIP: http://filips.net/archives/2008/01/17/getting-badimageformatexception-in-64-bit-windows/

Have you been running/developing .NET programs in 64-bit Windows and met the BadImageFormatException? Well, Microsoft might say: “The exception that is thrown when the file image of a DLL or an executable program is invalid.” Which says absolutely nothing… :)

However, if it happens when using Platform Invove (P/Invoke or DllImport) or a third .NET party library (DLL) then you might have to set the project’s properties (or compilation flags) from “any” platform target to “x86″. Also, remember to set change to x86 in both the debug and release build configurations while you are at it, otherwise it might seem to only work when you are debugging and not in release compilation.

(This happened to me when I used a .NET code library for a LabJack device in a program and ran the program under 64-bit Vista. Couldn’t find what the nature of the problem “really” was… )

Dec 16, 2009 at 10:40 PM

64 bit. Yes, forgot about that! Do I need to recompile the dll?

Coordinator
Dec 18, 2009 at 6:29 PM

yes, this is probably the issue. NAudio is marked as x86 only at the moment, as a number of the interop signatures are not x64 ready yet. hopefully this can be fixed for a future version

Mark

Dec 20, 2009 at 4:10 AM

Thanks for the info. I'll use a x86 virtual machine for now.

Jan 9, 2010 at 7:53 PM

I'm using NAudio on an ASP.NET application. I use Win7 x64 w/ VS 2010beta.  I found that tweaking the IIS application pool to allow 32-bit apps worked, such as described here .

 

Bryan

 

Mar 29, 2010 at 11:08 AM

We're in the same situation. I'm using vista 64bit. I need to adjust project built from anycpu to x86. It works 4 me.

Coordinator
Mar 29, 2010 at 11:24 AM

Hi spaceman27,

I've recently checked in some changes to NAudio that will hopefully fully support x64 without the need to adjust the target CPU. I will post an announcement on my blog once it is all working

Mark

Mar 29, 2010 at 5:13 PM
thanks!

On Mon, Mar 29, 2010 at 3:24 AM, markheath <notifications@codeplex.com> wrote:

From: markheath

Hi spaceman27,

I've recently checked in some changes to NAudio that will hopefully fully support x64 without the need to adjust the target CPU. I will post an announcement on my blog once it is all working

Mark

Read the full discussion online.

To add a post to this discussion, reply to this email (naudio@discussions.codeplex.com)

To start a new discussion for this project, email naudio@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com