我使用模式MVVM Caliburn Micro,在我的ViewModel中我有这个代码
private Microphone microphone;
private byte[] buffer;
private MemoryStream stream;
public MainViewModel()
{
microphone = Microphone.Default;
stream = new MemoryStream();
DispatcherTimer dt = new DispatcherTimer();
dt.Interval = TimeSpan.FromMilliseconds(50);
dt.Tick += delegate
{
try
{
FrameworkDispatcher.Update();
}
catch { }
};
dt.Start();
microphone.BufferReady += new EventHandler<EventArgs>(microphone_BufferReady);
}
void microphone_BufferReady(object sender, EventArgs e)
{
//...
}
就此而言
microphone.BufferReady += new EventHandler<EventArgs>(microphone_BufferReady);
收到错误=&gt; System.NullReferenceException:未将对象引用设置为对象的实例