我的程序时一个WPF的播放器应用程序。目前碰到一个如标题所示的错误。
我自己写了一个Player.cs
public Player( Dispatcher dispatcher, IListener listener, int i )
{
this.listener = listener;
this.dispatcher = dispatcher;
window_id = i;
}
其次在MainWindow.xaml.cs中创建实例:
private Player mediaplayer1 = null;
在程序内部对其进行赋值
mediaplayer1 = new Player(this.Dispatcher, this, 1);
如果赋值这句语句放在InitializeComponent();之前就不会有错,放在InitializeComponent();之后就会出错。
调试后输出栏输出内容如下:
在 System.NullReferenceException 中第一次偶然出现的“WPF.exe”类型的异常
在 System.NullReferenceException 中第一次偶然出现的“System.Xaml.dll”类型的异常
在 System.NullReferenceException 中第一次偶然出现的“PresentationFramework.dll”类型的异常
在 System.Reflection.TargetInvocationException 中第一次偶然出现的“mscorlib.dll”类型的异常
在 System.Reflection.TargetInvocationException 中第一次偶然出现的“mscorlib.dll”类型的异常
在 System.Reflection.TargetInvocationException 中第一次偶然出现的“System.Xaml.dll”类型的异常
在 System.Reflection.TargetInvocationException 中第一次偶然出现的“PresentationFramework.dll”类型的异常
“System.Reflection.TargetInvocationException”类型的未经处理的异常出现在 PresentationFramework.dll 中。
大神们帮帮忙呀