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

Visual Studio 2010 crashes loading project using Naudio.dll - heap corruption

Mar 19, 2013 at 3:46 PM
I wrote a simple project in C# using Naudio.dll. It seems to work fine, but Visual Studio crashes very often when loading the project. Event viewer says

Application: VCSExpress.exe
Frameworkversion: v4.0.30319
Beschreibung: Der Prozess wurde aufgrund eines internen Fehlers in der .NET-Laufzeit beendet. bei IP 7922380C (79140000) mit Exitcode 80131506.

(Process has been terminated due to internal error in .NET runtime at IP 7922380C). Exitcode was 80131506.

Target Runtime is 4.0. I'm using NAudio v1.6

Re-opening the project and opening all source files manually solves the problem.

The exit code tells that there seems to be a sort of heap corruption. What can I do to solve this issue?

Mar 19, 2013 at 4:55 PM
I have no idea what might be causing Visual Studio to crash when you load a project. Why do you think that NAudio is the cause of the problem?
Mar 19, 2013 at 8:55 PM
Well, loading the NAudio.dll is the only (call it) "unusual thing" the project does at startup. And - especially thought on heap corruption in
connection with managed and unmanaged code - the rest of the project is plain standard C# without any specialities. I have in mind
that heap corruption might occur in connection with managed and unmanaged code?!?

BTW, interesting point: when You reload the project, VS excludes several files from loading and only loads them if you need them. When You reload
the project, it crashes when You try to open Form1.cs as first file. But when You've opened other files before (i.e. Program.cs or Form1.resx), it
won't crash... funny behaviour... Perhaps Naudio.dll needs some time to load?!?

I will give it a cross-check and delete the reference to NAudio.dll and see if VS is still crashing when loading the project.
I can do this tomorrow when I'm back in the office. So I'll try and post the results here.

Mar 20, 2013 at 4:47 PM
VS shouldn't run any NAudio code on project load, except possibly if the Designer has some NAudio components on it. Is this the case?
Mar 22, 2013 at 7:56 AM
Hi! Sorry, took me a couple of days to test it. Mark, I guess You're right. I re-coded the whole project in VB2008 and it works like a charm. So I have to check
what's up with my VS C# installation.

Another strange thing I was wondering about is:
  • i record audio stream from my sound card via ASIO
  • ASIO buffer size is 512
  • i use two alternating buffers (array of type Single) in the Software to cache the samples
  • every time a buffer is full i switch over to the other buffer and try to flush (async) the first buffer to disk (binarywriter with RAW data, no wave writer!)
The thing is:
If i import two consecutive RAW files in Audacity, I get a gap of one sample between the two files.
On the other hand, if I merge the two files together (by some external command), everything is fine. Perhaps a problem in audacity?!?