보호 된 메모리를 읽거나 쓰려고했습니다. 이것은 종종 다른 메모리가 손상되었음을 나타냅니다.
누군가이 오류를 일으킬 수있는 것에 대해 누군가를 깨달을 수 있기를 바랍니다.
보호 된 메모리를 읽거나 쓰려고했습니다. 이것은 종종 다른 메모리가 손상되었음을 나타냅니다.
이 오류는 응용 프로그램의 임의의 영역에서 발생하는 것으로 보이므로 실제로 코드를 게시 할 수 없습니다. 응용 프로그램은 오류가 발생하기 전에 12-48 시간 동안 실행됩니다. 때로는 겉보기에 임의의 지점에서 멈추고 위의 오류가 발생합니다. 다른 경우 전체 응용 프로그램이 중지되고 "치명적인 오류가 발생했습니다 ... '라는 줄에 오류가있는 화면이 나타납니다. CLR의 버그 또는 ... "PInvoke 또는 기타 관련이없는 정보에 관한 정보. 이 경우 모든 스레드가 종료 된 것으로 표시되고 사용 가능한 디버깅 정보가 없습니다.
간단히 말해서 이것은 응용 프로그램이하는 일입니다.
C #으로 작성된 멀티 스레드 서버 응용 프로그램입니다. 클라이언트는 소켓을 통해 서버에 연결됩니다. 서버는 클라이언트가 서로 및 환경과 상호 작용할 수있는 가상 환경을 실행합니다. 꽤 많은 메모리를 소비하지만 누수가 보이지 않습니다. 일반적으로 약 1.5GB를 소비합니다. 메모리 사용량이 응용 프로그램이 실행되는 동안 전체적으로 상대적으로 일정하기 때문에 누수가 있다고 생각하지 않습니다. 클라이언트가 아무것도하지 않더라도 환경을 유지하기 위해 지속적으로 코드를 실행합니다. 타사 소프트웨어 나 다른 API를 사용하지 않습니다. 이 응용 프로그램에서 사용하는 유일한 외부 리소스는 소켓 연결 및 SQL 데이터베이스 연결입니다. 64 비트 서버에서 실행 중입니다. VS2008 및 VS2010에서 .net 2.0, 3.5 및 4를 사용하여 디버깅하려고했습니다.
컴파일러 최적화와 여러 Microsoft 핫픽스를 끄려고했습니다. 이 문제가 사라지는 것은 없습니다. 가능한 원인 또는 문제를 일으키는 원인을 식별 할 수있는 방법을 아는 사람이 있다면 감사하겠습니다.
VS 2013 .NET 4.5에서 MapInfo DLL을 사용 하여이 문제에 직면했습니다. 문제는 내가 빌드 플랫폼을 x86에서 모든 CPU로 변경 했으며이 오류를 발생시키기에 충분하다는 것이 문제였습니다. 다시 x86으로 변경하면 트릭이되었습니다. 누군가를 도울 수 있습니다.
마지막으로 WinDBG 및 SOS의 도움으로이를 추적했습니다. 알 수없는 DLL에 의해 액세스 위반이 발생했습니다. "Nvidia Network Manager"라는 소프트웨어가 문제를 일으키는 것으로 나타났습니다. 방화벽이나 바이러스 백신으로 인해이 문제가 발생할 수있는 방법을 셀 수없이 많이 읽었으며 어느 것도 사용하지 않으므로이 아이디어를 무시했습니다. 또한 다른 하드웨어를 사용하는 둘 이상의 서버에서 발생하기 때문에 환경이 아니라고 가정했습니다. 이 컴퓨터에서 테스트 한 모든 컴퓨터가 "NVidia Network Manager"를 실행하고있었습니다. 나는 그것이 다른 마더 보드 드라이버와 함께 설치된다고 생각합니다.
이 문제가 오랫동안 내 응용 프로그램을 괴롭 혔기 때문에 누군가에게 도움이되기를 바랍니다.
또한 Visual Studio 2010에서이 문제에 직면했습니다. 더 흥미롭게도 솔루션 (콘솔 응용 프로그램, WPF 응용 프로그램, Windows Forms 응용 프로그램)에 여러 프로젝트가 있지만 "Console Application"유형의 프로젝트를 설정할 때만 실패했습니다. "시작 프로젝트로 (프로젝트 템플릿 자체와 함께 제공되는 기본 어셈블리와 별도로 참조 된 코드 나 추가 어셈블리가없는 경우에도).
콘솔 애플리케이션 프로젝트의 프로젝트 속성으로 이동 Debug
-> 탭으로 이동-> Enable Debuggers
오른쪽 창에서 섹션으로 이동 -> Enable unmanaged code debugging
아래 스냅 샷과 같이 확인란을 선택 하면 변경 사항이 문제를 해결하는 데 도움이되었습니다 . 왜 그런 일이 있었는지 근본 원인은 아직 알려지지 않았습니다. 내가 관찰 한 유일한 것은 전날 밤 내 컴퓨터에 많은 Windows 업데이트가 설치되어 사무실 업데이트와 OS 업데이트로 구성되었다는 것입니다 (12 KB 이상의 기사).
이 명령을 실행하십시오
netsh winsock 재설정
출처 : https://stackoverflow.com/a/20492181/1057791
The problem may be due to mixed build platforms DLLs in the project. i.e You build your project to Any CPU but have some DLLs in the project already built for x86 platform. These will cause random crashes because of different memory mapping of 32bit and 64bit architecture. If all the DLLs are built for one platform the problem can be solved.
This error should not happen in the managed code. This might solve the issue:
Go to Visual Studio Debugger to bypass this exception:
Tools menu ->Options -> Debugging -> General -> Uncheck this option "Suppress JIT optimization on module load"
Hope it will help.
I had this problem recently when I changed the development server for a project. I was getting this error on the line of code where I declared a new OracleConnection variable.
After trying many things, including installing hotfixes, I tried changing the references Oracle.DataAccess and System.Data.OracleClient in the project and it worked!
When a project is moved to a new machine, I suggest you renew all the references added in that project.
I've ran into, and found a resolution to this exception today. It was occurring when I was trying to debug a unit test (NUnit) that called a virtual method on an abstract class.
The issue appears to be with the .NET 4.5.1 install.
I have downloaded .NET 4.5.2 and installed (my projects still reference .NET 4.5.1) and the issue is resolved.
Source of solution:
Did you try turning off DEP (Data Execution Prevention) for your application ?
It could be hardware. It could be something complicated...but I'd take a stab at suggesting that somewhere your threading code is not protecting some collection (such as a dictionary) with an appropriate lock.
What OS and service pack are you running?
Verifiable code should not be able to corrupt memory, so there's something unsafe going on. Are you using any unsafe code anywhere, such as in buffer processing? Also, the stuff about PInvoke may not be irrelevant, as PInvoke involves a transition to unmanaged code and associated marshaling.
My best recommendation is to attach to a crashed instance and use WinDBG and SOS to dig deeper into what's happening at the time of the crash. This is not for the faint of heart, but at this point you may need to break out more powerful tools to determine what, exactly, is going wrong.
I faced the same issue. My code was a .NET dll (AutoCAD extension) running inside AutoCAD 2012. I am also using Oracle.DataAccess and my code was throwing the same exception during ExecuteNonQuery(). I luckily solved this problem by changing the .net version of the ODP I was using (that is, 2.x of Oracle.DataAccess)
Ok, this could be pretty useless and simply anecdotal, but...
This exception was thrown consistently by some Twain32 libraries we were using in my project, but would only happen in my machine.
I tried lots of suggested solutions all over the internet, to no avail... Until I unplugged my cellphone (it was connected through the USB).
And it worked.
Turns out the Twain32 libraries were trying to list my phone as a Twain compatible device, and something it did in that process caused that exception.
Go figure...
in my case the file was open and therefore locked.
I was getting it when trying to load an Excel file using LinqToExcel that was also opened in Excel.
this is all I deeded
var maps = from f in book.Worksheet<NavMapping>()
select f;
try {
foreach (var m in maps)
if (!string.IsNullOrEmpty(m.SSS_ID) && _mappings.ContainsKey(m.SSS_ID))
_mappings.Add(m.SSS_ID, m.CDS_ID);
} catch (AccessViolationException ex) {
_logger.Error("mapping file error. most likely this file is locked or open. " + ex);
}
This issue is almost invariably a simple one. The code is bad. It's rarely the tools, just from a statistical analysis. Untold millions of people are using Visual Studio every day and maybe a few are using your code - which bit of code is getting the better testing? I guarantee that, if this were a problem with VS, we would probably already have found it.
What the statement means is that, when you try to access memory that isn't yours, it's usually because you're doing it with a corrupted pointer, that came from somewhere else. That's why it's stating the indication.
With memory corruption, the catching of the error is rarely near the root cause of the error. And the effects are exactly what you describe, seemingly random. You'll just have to look at the usual culprits, things like:
- uninitialised pointers or other values.
- writing more to a buffer than its size.
- resources shared by threads that aren't protected by mutexes.
Working backwards from a problem like this to find the root cause is incredibly difficult given that so much could have happened between the creation of the problem and the detection of the problem.
I mostly find it's easier to have a look at what is corrupt (say, a specific pointer) and then do manual static analysis of the code to see what could have corrupted it, checking for the usual culprits as shown above. However, even this won't catch long chains of problems.
I'm not familiar enough with VS to know but you may also want to look into the possibility of using a memory tracking tool (like valgrind for Linux) to see if it can spot any obvious issues.
i had this problem too . i was running different solutions at the same time using visual studio , when closing other solutions and running just the target solution , it worked fine without that error .
I got the same error in a project I was working with in VB.NET. Checking the "Enable application framework" on the properties page solved it for me.
Got this error randomly in VS1017, when trying to build a project that was building perfectly fine the day before. Restarting the PC fixed the issue worked (I also ran the following command beforehand, not sure if it's required: netsh winsock reset)
I got this error when using pinvoke on a method that takes a reference to a StringBuilder
. I had used the default constructor which apparently only allocates 16 bytes. Windows tried to put more than 16 bytes in the buffer and caused a buffer overrun.
Instead of
StringBuilder windowText = new StringBuilder(); // Likely overflow of default capacity of 16
Use a larger capacity:
StringBuilder windowText = new StringBuilder(3000);
My answer very much depends on your scenario but we had an issue trying to upgrade a .NET application for a client which was > 10 years old so they could make it work on Windows 8.1. @alhazen's answer was kind of in the correct ballpark for me. The application was relying on a third-party DLL the client didn't want to pay to update (Pegasus/Accusoft ImagXpress). We re-targeted the application for .NET 4.5 but each time the following line executed we received the AccessViolationException was unhandled
message:
UnlockPICImagXpress.PS_Unlock (1908228217,373714400,1341834561,28447);
To fix it, we had to add the following post-build event to the project:
call "$(DevEnvDir)..\tools\vsvars32.bat"
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\amd64\editbin.exe" /NXCOMPAT:NO "$(TargetPath)"
This explicitly specifies the executable as incompatible with Data Execution Prevention. For more details see here.
In some cases, this might happen when:
obj = new obj();
...
obj.Dispose(); // <----------------- Incorrect disposal causes it
obj.abc...
필자의 경우 P / Invoke를 사용하여 C / C ++ 라이브러리를 참조해야했지만 다음을 사용하여 메모리가 출력 배열에 먼저 할당되었는지 확인해야했습니다 fixed
.
[DllImport("my_c_func_lib.dll", CharSet = CharSet.Ansi)]
public static extern unsafe int my_c_func(double input1, double input2, double pinput3, double *outData);
public unsafe double[] GetMyUnmanagedCodeValue(double input1, double input2, double input3)
{
double[] outData = new double[24];
fixed (double* returnValue = outData)
{
my_c_func(input1, input2, pinput3, returnValue);
}
return outData;
}
자세한 내용은 https://www.c-sharpcorner.com/article/pointers-in-C-Sharp/ 를 참조하십시오.
'Programming' 카테고리의 다른 글
'+'오류 전에 JSHint의 잘못된 줄 바꿈에 대한 설명 (0) | 2020.07.10 |
---|---|
내가하고있는 모든 일이 커밋을 저지르는 것인데 왜 git-rebase가 병합 충돌을 제공합니까? (0) | 2020.07.10 |
** kwargs를 사용하여 ** kwargs 인수를 다른 함수에 전달 (0) | 2020.07.10 |
통합 테스트와 기능 테스트의 차이점은 무엇입니까? (0) | 2020.07.10 |
지옥을 보호-참조 클래스를 찾을 수 없습니다 (0) | 2020.07.10 |