Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Friday, August 24, 2018 5:22 AM
"Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt"
This kind of issue happens all the time. I am using visual basics 2010 and using .Net 4
I have already tried this below setting option but still it shows the same warning!!
Tools menu ->Options -> Debugging -> General -> Uncheck this option "Suppress JIT optimization on module load"
Will you give me a suggestion to surpass this issue!
All replies (5)
Friday, August 24, 2018 5:47 AM
Normally this error would never happen if you were only using Managed Code. The fact that you have managed to corrupt the memory indicates that at some point in your program you are calling some unmanaged code, and there is a mistake in that code. This could happen if you are calling an external DLL using [DllImport] and the extern declaration is wrong or you are pasing the wrong parameters. It can also happen if you invoke a COM object and there is a mistake in the COM or its type library. And also if you use a third-party library or component that itself contains unmanaged code and there is a mistake in that code. Oh, and another thing: you can also corrupt memory if you use multithreaded code and manipulate the UI from a thread that is different from the thread that created the UI.
The solution is to isolate the specific part of the code that produces one of the above problems and then fix whatever is wrong in it. There is no "magical" remedy such as changing an option in Visual Studo.
Friday, August 24, 2018 2:13 PM
This is the C# forums. You said you're using VB, is that correct?
Michael Taylor http://www.michaeltaylorp3.net
Friday, August 24, 2018 3:11 PM
You said you're using VB, is that correct?
He said so, but it doesn't matter. The error would be the same in either language, and the causes would be the same, and the steps to solve it would be the same. The OP could even be using a hybrid solution combining C# and VB.NET assemblies, and the response would still be the same.
Friday, August 24, 2018 3:17 PM
I disagree. In C# you can use unchecked and unsafe to do unmanaged work without ever using DllImport. VB doesn't support either of these. Without seeing the code that is no way of knowing hence the question.
Michael Taylor http://www.michaeltaylorp3.net
Monday, August 27, 2018 3:06 AM
Hi,
According to your description and related error message, it seems that the exception is threwn by some DLL, I would suggest that you could track the issue by using WinDBG and SOS and check what dll cause the issue.
Best regards,
Zhanglong
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].