我有这些课程:
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;
}
答案 0 :(得分:0)
我修复了它,我在Form1中运行了一个无限循环。 Form1启动Server和Server访问Form1。 现在我创建了Start.cs,它在第二个线程中启动Server和Form1。
需要一些调用回调