2

내 카메라에서 스트림을 렌더링은 작업자 스레드를 사용하여System.AccessViolationException : 당신이 볼 수있는 .NET 런타임 오류 C# 작업자 스레드 내 창문의 형태로 PictureBox를이

Application: nMCR.exe 
Framework Version: v4.0.30319 
Description: The process was terminated due to an unhandled exception. 
Exception Info: System.AccessViolationException 
    at <Module>.av_read_frame(libffmpeg.AVFormatContext*, libffmpeg.AVPacket*) 
    at Accord.Video.FFMPEG.VideoFileReader.readVideoFrame(Int32, System.Drawing.Imaging.BitmapData) 
    at Accord.Video.FFMPEG.VideoFileReader.ReadVideoFrame() 
    at nMCR.form.MainForm.updateui() 
    at System.Threading.ThreadHelper.ThreadStart_Context(System.Object) 
    at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) 
    at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) 
    at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) 
    at System.Threading.ThreadHelper.ThreadStart() 

내 버튼 코드 :

때문에 내 양식 .IN 메모리 사용의 프레임은 내가 몇 시간 동안 버튼을 클릭하면 video.But의 판을 감지하는 pictureRTSP.BackgroundImage을 사용하는 버튼이 난이 오류가

BitmapImage bmImage = null;

 if (IsRTSP) 
     { 
      //FinalImage = new Bitmap(_snapshotHandler.TakeSnapshot().ToImage()); 

       FinalImage = new Bitmap(pictureRTSP.BackgroundImage); 



      //Bitmap img = (Bitmap)Image.FromStream(FinalImage); 
      bmImage = new BitmapImage(); 

      using (MemoryStream memStream2 = new MemoryStream()) 
      { 
       FinalImage.Save(memStream2, System.Drawing.Imaging.ImageFormat.Png); 
       memStream2.Position = 0; 

       bmImage.BeginInit(); 
       bmImage.CacheOption = BitmapCacheOption.OnLoad; 
       bmImage.UriSource = null; 
       bmImage.StreamSource = memStream2; 
       bmImage.EndInit(); 
      } 

enter image description here

+0

@Fildor 단지 참조 내 오류 .I이 원하는을 내가 왜이 오류가 발생하는지 알고 싶습니까? –

+0

@Fildor 내가 세부 사항을 알려주시겠습니까? –

+0

@Fildor 네 정확히 .i 어떤 줄에서 오류가 발생했는지 보여주는 그림을 게시하십시오. –

답변

2

먼저 당신이 비디오 판독기를 여는 문제가, 당신의 솔루션의 플랫폼 대상에 문제가 있다고 생각, 그것을 32 비트를 만드는 시도, C를 사용하는 일부 라이브러리 ++ 네이티브 내부의 dll은 32 비트 일 수 있으며 AnyCPU에서는 작동하지 않습니다.

둘째 당신은 메인 스레드가 아닌 다른 스레드에서 picturebox의 배경 이미지를 변경 :

picturebox 이미지 변경시 호출을 호출하려고 :

this.Invoke(new Action(()=> pictureRTSP.BackgroundImage = currentFrame)); 
+0

Stacktrace에서 문제가 발생하는 동안 그 줄 앞에 감지 된 예외가 발생하는 것으로 보입니다. – Fildor

+0

테스트하려고합니다. –

+0

동일한 오류가 반환되었습니다 –