This project has moved and is read-only. For the latest updates, please go here.

NAudio crashes on startup.

Oct 7, 2011 at 3:33 PM

Any one have idea on what is wrong?

I'm trying to test out the samples on a x64 machine. after I unzip, running any demo app gives the following error.

It also freezes visual studios 2010 when I try to compile the solution..

System.BadImageFormatException: Could not load file or assembly 'NAudio, Version=1.4.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
File name: 'NAudio, Version=1.4.0.0, Culture=neutral, PublicKeyToken=null'
   at NAudioDemo.AudioPlaybackForm.InitializeComponent()
   at NAudioDemo.AudioPlaybackForm..ctor()
   at NAudioDemo.MainForm.buttonWavPlayback_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

 

************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5446 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll
----------------------------------------
NAudioDemo
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Users/ninghu/Downloads/NAudio/NAudioDemo.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5446 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5447 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
Accessibility
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------

Oct 12, 2011 at 4:27 PM

I have the same problem =(

 

Win 7 64bits

Oct 12, 2011 at 4:29 PM

this should be fixed with the latest code.

Oct 12, 2011 at 5:04 PM

I have the latest code. I download today the 1.4 version. I'm using VS2008.

Oct 12, 2011 at 5:05 PM

Not 1.4, the latest code from the Source Code tab above

Oct 12, 2011 at 5:11 PM

And then? I was using only the dll file and in the source code there is no NAudio.dll file =/

Oct 12, 2011 at 5:14 PM

you have to rebuild the source to use the latest version

Oct 12, 2011 at 5:30 PM

I only have VS2008 and project NAudio.sln was made in VS2010 (I think)...

Any way to I have the compiled dll?

Thank you for your fast replys and sorry for my english

Oct 12, 2011 at 5:32 PM

I will try to make a newer build available (about to go out, so won't be done today I'm afraid). To do it yourself, you could try using Visual Studio Express 2010 which is a free product

Oct 12, 2011 at 5:39 PM
markheath wrote:

I will try to make a newer build available (about to go out, so won't be done today I'm afraid). To do it yourself, you could try using Visual Studio Express 2010 which is a free product

It's my exact same idea ;) I'm installing Visual Studio Express 2010 right now =)

Oct 13, 2011 at 10:37 AM
Edited Oct 13, 2011 at 10:38 AM

The problem persists =(

I install VS 2010 Express, build the solution in Debug mode try NAudio.dll from \NAudio\bin\Debug and same problem.

After I try build the solution in Release mode use NAudio.dll from \NAudio\bin\Release and nothing... same thing =(

Am I trying with the right file?

Oct 13, 2011 at 10:42 AM

Go into the NAudio project properties and change the target platform to AnyCPU. I thought I had done so in the latest check-in, (it will be for NAudio 1.5), but maybe not. I only got an x64 dev machine myself recently, and I did a bunch of testing in x64 mode and all is looking good.

The other alternative for you is to use the NAudio dll as is, but set the target platform of your host executable to x86, which is what you were supposed to do with NAudio 1.4 and below.

Oct 13, 2011 at 11:16 AM
markheath wrote:

Go into the NAudio project properties and change the target platform to AnyCPU. I thought I had done so in the latest check-in, (it will be for NAudio 1.5), but maybe not. I only got an x64 dev machine myself recently, and I did a bunch of testing in x64 mode and all is looking good.

Everything is set to Any CPU.

 

markheath wrote:

The other alternative for you is to use the NAudio dll as is, but set the target platform of your host executable to x86, which is what you were supposed to do with NAudio 1.4 and below.

I don't thing if I follow you... My host was a x64 plataform and I try to buil as a x86 with dll 1.4 and now with this new dll =(

I only want to convert a mp3 file to wav.... I try Lame.exe but with no success and I see your dll was a alternative, but I thing I not have any progresses.

Thank you anyway for all your help attemps

There is the error:

Could not load file or assembly 'NAudio' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.BadImageFormatException: Could not load file or assembly 'NAudio' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Assembly Load Trace: The following information can be helpful to determine why the assembly 'NAudio' could not be loaded.

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].


Stack Trace: 

[BadImageFormatException: Could not load file or assembly 'NAudio' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
   System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +416
   System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +166
   System.Reflection.Assembly.Load(String assemblyString) +35
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +190

[ConfigurationErrorsException: Could not load file or assembly 'NAudio' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +11224200
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +388
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +232
   System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +48
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +210
   System.Web.Compilation.BuildProvidersCompiler..ctor(VirtualPath configPath, Boolean supportLocalization, String outputAssemblyName) +76
   System.Web.Compilation.CodeDirectoryCompiler.GetCodeDirectoryAssembly(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories, Boolean isDirectoryAllowed) +11213378
   System.Web.Compilation.BuildManager.CompileCodeDirectory(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories) +185
   System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +551

[HttpException (0x80004005): Could not load file or assembly 'NAudio' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +76
   System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +1012
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters) +1025

[HttpException (0x80004005): Could not load file or assembly 'NAudio' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11318198
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +88
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4348404

Oct 13, 2011 at 11:20 AM

This error means that you are running as an x64 process and you have a build of NAudio.dll that is set to target x86 only.

You fix it by either running as x86 process (not sure how you do this with IIS), OR, rebuild NAudio.dll with the AnyCPU target set.

Oct 17, 2011 at 6:10 PM

I force everything to go x64 (AnyCPU does not do the work correctly) and it works.

Thank you

Jan 29, 2012 at 12:43 PM

Reconfirming gelasio's finding with December's 1.5 release. AnyCPU throws the exception, x64/x86 does not.

Jan 29, 2012 at 1:03 PM

@Artfunkel. That is very strange. Are you also using NAudio from IIS? What class within NAudio are you using when the crash occurs.

Feb 11, 2012 at 12:20 AM

I'm not using ISS, I'm using a regular DLL build of the library.

I'm not using any particular class. The exception happens as soon as any function with NAudio objects is reached. Here's all the info:

 

System.BadImageFormatException was unhandled by user code
  Message=Could not load file or assembly 'NAudio, Version=1.5.4.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
  Source=Ego Audio Tool
  FileName=NAudio, Version=1.5.4.0, Culture=neutral, PublicKeyToken=null
  FusionLog==== Pre-bind state information ===
LOG: User = Tom-PC\Tom
LOG: DisplayName = NAudio, Version=1.5.4.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Users/Tom/Documents/Visual Studio 2010/Projects/EgoMusicEditor/EgoMusicEditor/bin/Release/
LOG: Initial PrivatePath = NULL
Calling assembly : Ego Audio Tool, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\Tom\Documents\Visual Studio 2010\Projects\EgoMusicEditor\EgoMusicEditor\bin\Release\Ego Audio Tool.vshost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/Tom/Documents/Visual Studio 2010/Projects/EgoMusicEditor/EgoMusicEditor/bin/Release/NAudio.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

  StackTrace:
       at Ego.AudioTool.EgoAudioTool.StopSample()
       at Ego.AudioTool.EgoAudioTool.LoadDictionaries() in C:\Users\Tom\Documents\Visual Studio 2010\Projects\EgoMusicEditor\EgoMusicEditor\App.xaml.cs:line 82
       at Ego.AudioTool.EgoAudioTool.AppState.set_CurrentGame(Game value) in C:\Users\Tom\Documents\Visual Studio 2010\Projects\EgoMusicEditor\EgoMusicEditor\App.xaml.cs:line 230
       at Ego.AudioTool.MainWindow.ChangeGame() in C:\Users\Tom\Documents\Visual Studio 2010\Projects\EgoMusicEditor\EgoMusicEditor\Windows\MainWindow.xaml.cs:line 186
  InnerException: 

I'm using a .net 4 build, but changing to 2 or 3 doesn't help.

 

Feb 11, 2012 at 7:48 AM

Are you able to make a very simple application that has this problem and upload a copy for me to have a look at?

thanks

Mark