2

내가 이것을 실행하려고 :C++/CLI에서 std :: basic_ifstream :: get()을 사용할 때 AccessViolationException이 발생하는 이유는 무엇입니까?

[email protected]() + 0xae bytes 
[email protected]() + 0xa1 bytes 
[email protected]() - 0x1f885 bytes 
msvcr120.dll!__lock_file() + 0x2ce45 bytes 
[Managed to Native Transition] 
MyProject.exe!std::basic_filebuf<char,std::char_traits<char> >::_Lock() Line 355 C++ 
msvcp120d.dll!std::basic_istream<char,std::char_traits<char> >::_Sentry_base::_Sentry_base() + 0x55 bytes 
msvcp120d.dll!std::basic_istream<char,std::char_traits<char> >::sentry::sentry() + 0x32 bytes 
msvcp120d.dll!std::basic_istream<char,std::char_traits<char> >::get() + 0x5c bytes 
[Managed to Native Transition] 
MyProject.exe!wmain(int argc = 0x2, wchar_t** argv = 0x054AA3F8) [line # removed] C++ 
MyProject.exe!__tmainCRTStartup() [line # removed] C 
[Managed to Native Transition] 
[email protected]() + 0x71 bytes 
[email protected]() + 0x227 bytes 
[email protected]() + 0x8 bytes 
[email protected]() + 0x27 bytes 
[email protected]() + 0x1b bytes  

왜 이런 일이 않으며, 파일을 읽으려고 할 때 어떻게 내가 그것을 피할 수 :

#include <tchar.h> 
#include <fstream> 

int _tmain(int argc, TCHAR *argv[]) 
{ 
    std::basic_ifstream<TCHAR> file("TestInput.txt"); 
    file.get(); 
} 

내가이 스택 트레이스와 함께 AccessViolationException을 얻을?

+1

왜 저에게는 그런 느낌이 들지 않았습니까?/ – chris

+0

@chris : 그래, 같은 느낌이 들었습니다. 왜 그 중 하나가 VS 2013에 있습니까? – Mehrdad

+0

예, 파일을 만들지 않았지만 시도해 볼 수도 있습니다. – chris

답변

0

_DEBUG 매크로로 컴파일 중이었기 때문에 (네이티브에서 변환하기 전에 남겨 둡니다). 제거하면 문제가 해결되었습니다.

+0

'_DEBUG' 심볼은이 예외의 원인이 무엇입니까? – Anthony

+0

@ anthony-arnold : 잘 모르겠다. – Mehrdad

0

예기치 않은 일을하는 매크로가있는 것 같습니다. Visual C++에서 어떤 일이 발생했는지 알아 내야 할 때 전 처리기 출력을 덤프하십시오. 그 일에 대한 자세한 내용은 here에 설명되어 있습니다.

관련 문제