At the moment I am trying to open up my first video file in a winform application using this VLC library
As far as I can tell, I have it all set up properly. I have followed all of the source code that the sample projects give and created my winform in the style of the sample project. When I run the project and open up my file, I get a Null Reference Exception
on the following code, namely the line vlcControl.Media = media;
:
if (openFileDialog.ShowDialog(this) == DialogResult.OK)
{
var media = new PathMedia(openFileDialog.FileName);
vlcControl.Media = media;
}
I know null reference errors happen because I haven't initialized something, but to my eyes, media has already been set to a new object. So why is my compiler throwing a fit?
Update I've fixed the issue. I had to rebuild and re-add a dll that had a fix for this issue. Thank you for your help.
There are two options that could cause this.
vlcControl
is null (hasn't been constructed or initialized) at that point. This will cause the exception to occur since you're trying to access the Media
property. vlcControl
is raising the exception because it's internal state is not setup properly. If setting the Media
property causes code to run internally, and the state is not setup properly, this can raise the exception. You should be able to look at the exception details or the locals window (to check for vlcControl
being null
) to determine where the problem lies.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.