المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Using lame_enc.dll in .NET - Signature mismatch



C# Programming
05-29-2012, 10:40 AM
I'm working on a program that will convert a wav-file to mp3, tag it and then upload it via FTP.

I'm done with the FTP-part and am now working on the converting to MP3 part (the only thing left).
The plan is to use LAME (lame_enc.dll) to do the encoding/converting (unless you have any other suggestion). But I've hit a snag.

I couldn't find any good examples for Lame & .NET. I found this here on TCP: C# MP3 Compressor (http://www.codeproject.com/Articles/5901/C-MP3-Compressor)[^ (http://www.codeproject.com/Articles/5901/C-MP3-Compressor)]
It wouldn't compile due to missing form components, but I copied the the classes that's relevant.

The project compiles but I get an exception on the call to beInitStream (in the constructor of Mp3Writer). The error states: PInvokeStackImbalance was detectedand that "the managed PInvoke signature didn't match the unmanaged target signature" (translated from Swedish).

Is there anyone that has an idea what's wrong?! Is this code written for an older version of lame_enc.dll (I've looked at the documentation, but can't see the problem)?

I also tried to use IntPtr etc (found in another example for another DLL), but same result:
Marshal.StructureToPtr(Marshal.SizeOf(m_Mp3Config), Marshal.AllocHGlobal(pConfig), false); uint LameResult = Lame_encDll.beInitStream(ref pConfig, ref m_InputSamples, ref m_OutBufferSize, ref m_hLameStream);
Code for DLL import:

[DllImport("Lame_enc.dll")]public static extern uint beInitStream(ref BE_CONFIG pbeConfig, ref uint dwSamples, ref uint dwBufferSize, ref uint phbeStream);or
[DllImport("Lame_enc.dll")]public static extern uint beInitStream(ref IntPtr pbeConfig, ref uint dwSamples, ref uint dwBufferSize, ref uint phbeStream);
I could just call lame.exe, but I don't want to do it, mainly because I want to report the progress.

Glad for any help/ideas!