我正尝试使用BASS.NET库中的音频创建应用程序,但我在“我的第一个BASS应用程序”示例中收到了一些错误。我也跟着上http://bass.radio42.com/help/给定的方向,但是当我尝试运行粘贴代码,错误出现在这条线:“我的第一个BASS应用程序”BASS.NET应用程序错误
if (Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero))
我收到的错误是:
An unhandled exception of type 'System.TypeInitializationException' occurred in Bass Test.exe
我试图遵循所有的方向,但是#4,而不是添加bass.dll,我添加了bass.net.dll认为它是错字。
4.Copy the 'bass.dll' to your executable directory (e.g. .\bin\Debug).
的示例代码:
using System;
using Un4seen.Bass;
namespace MyFirstBass
{
class Program
{
static void Main(string[] args)
{
// init BASS using the default output device
if (Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero))
{
// create a stream channel from a file
int stream = Bass.BASS_StreamCreateFile("test.mp3", 0, 0, BASSFlag.BASS_DEFAULT);
if (stream != 0)
{
// play the stream channel
Bass.BASS_ChannelPlay(stream, false);
}
else
{
// error creating the stream
Console.WriteLine("Stream error: {0}", Bass.BASS_ErrorGetCode());
}
// wait for a key
Console.WriteLine("Press any key to exit");
Console.ReadKey(false);
// free the stream
Bass.BASS_StreamFree(stream);
// free BASS
Bass.BASS_Free();
}
}
}
}
我猜测的代码是不错,但我的电脑的输出设备是什么导致错误。
您是否尝试调试应用程序?错误发生在哪里?例外说.NET不能创建一个类型,可能是因为它找不到所有需要的dll。如果'bass.net.dll'只是'bass.dll'的一个包装文件,那么你的程序就需要两个DLL来工作 – 2014-10-07 07:04:15