I use a pattern MVVM Caliburn Micro and in my ViewModel I have this code
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)
{
//...
}
on this
microphone.BufferReady += new EventHandler<EventArgs>(microphone_BufferReady);
receive error => System.NullReferenceException: Object reference not set to an instance of an object
Is ID_CAP_MICROPHONE capability enabled in WMAppManifest.xml? Microphone.Default returns NULL if this is not enabled.