У меня есть эти классы:
Form1.cs
Server.cs
Теперь, когда я делаю в Server.cs
form1.startCapture("C:\\test.mp4");
Затем в Form1.CS
public void startCapture(String filename)
{
short result = this.axVideoCap1.Start();
}
Я получаю System.AccessViolationException
System.Runtime.InteropServices.COMException was unhandled.
Message = An attempt was made to read or write protected memory. This is often an indication that other memory is corrupt.
Source = mscorlib
Stack Trace:
at System.RuntimeType.ForwardCallToInvokeMember (String membername, BindingFlags flags, Object target, Int32 [] aWrapperTypes, Message & msgData)
at VIDEOCAPLib._DVideoCap.Start ()
at AxVIDEOCAPLib.AxVideoCap.Start ()
...
Как я могу решить эту ошибку?
public void startCapture(String filename)
{
this.axVideoCap1.CaptureVideo = this.captureVideoCheckBox.Checked;
this.axVideoCap1.CaptureAudio = this.captureAudioCheckBox.Checked;
this.axVideoCap1.ShowPreview = this.showPreviewCheckBox.Checked;
this.axVideoCap1.UseVideoCompressor = this.useVideoCapCheckBox.Checked;
this.axVideoCap1.UseAudioCompressor = this.useAudioCapCheckBox.Checked;
this.axVideoCap1.CaptureMode = true;
this.axVideoCap1.CaptureFileName = filename;
this.axVideoCap1.SyncMode = 1;
short result = this.axVideoCap1.Start();
switch (result)
{
case -1:
MessageBox.Show("Capture Failure,Video, Audio Compressor not correct or capture file opening");
return;
case -2:
MessageBox.Show("Capture file not found");
return;
}
this.previewButton.Enabled = false;
this.captureButton.Enabled = false;
this.stopButton.Enabled = true;
}