My legacy MFC application opens its own executable for reading (to compute its hash code to make tampering harder). To do so, it uses
CFile f( sExecFileName, CFile::modeRead | CFile::typeBinary );
This line starts throwing an CFileException with couse CFileException::sharingViolation when I compile the application, or even a small part of it not containing this code, with the /clr flag. This behavior occurs only if I compile “Debug” instead of “Release”, but even without attached debugger. What causes this and how do I fix it?
Disclaimer: My C++ is almost as good as my chinese (and I am not from China). Sorry if this question is trivial.
As stated by Hand Passant in the comment, I was missing
CFile::shareDenyNone.