machinelearning-samples icon indicating copy to clipboard operation
machinelearning-samples copied to clipboard

System.AccessViolationException: 'Attempted to read or write protected memory

Open billkearson opened this issue 3 years ago • 3 comments

System Windows 10 VS 2022

Download samples and tried to run the program: OnnxObjectDetection

Complies correctly and when I run the program an unhandled exception is thrown on line 25 var pipeline.

"An unhandled exception of type 'System.AccessViolationException' occurred in Microsoft.ML.OnnxRuntime.dll Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

The program '[19772] OnnxObjectDetectionApp.exe' has exited with code 3221225477 (0xc0000005) 'Access violation'."

Tried running VS 2022 as administrator and same issue. Tried changing to x64, x86, and Any CPU and same issue. Even rebooted same issue. Stuck.

Other samples such as DeepLearning_ObjectDetection_Onnx work fine, no issues.

Thank you.

billkearson avatar Jun 17 '22 00:06 billkearson

Try updating OpenCvSharp-AnyCPU to OpenCvSharp4. Also install the runtime for your OS. In case of Windows that is OpenCvSharp4.runtime.win

To be sure, you can also update the Microsoft.ML.* packages.

Ottodeklerk avatar Sep 30 '22 22:09 Ottodeklerk

Windows 10 VS 2022 .Net 6

Confirming that updating Microsoft.ML packages (to 1.7.1) and changing .Net target to .Net 6 worked for me. I did not need to make any changes to OpenCvSharp.

michaeltclark avatar Oct 16 '22 17:10 michaeltclark

Windows 10 VS 2022 .Net 6

Tried the workaround suggested by @michaeltclark and it did NOT work for me.

eduardomb08 avatar Jan 17 '23 21:01 eduardomb08