Why does app.config with a zero byte cause a very strange error?

Error

The volume for the file has been modified externally, so the open file is no longer valid.

This is because you have app.config, which is zero. The error appears from Windows - even WinDBG does not start it.

I know that it is completely invalid to have a byte of app.config null, but what causes this error, where does it come from and why is this happening?

+6
source share
1 answer
// // MessageId: ERROR_FILE_INVALID // // MessageText: // // The volume for a file has been externally altered so that the opened file is no longer valid. // #define ERROR_FILE_INVALID 1006L 

Copied from the WinError.h Windows SDK header file. The symbolic error code here is obviously much more relevant than the text of the template error message. This is not entirely unusual. I see that it is used inside the SSCLI20 source code (the open source version of the CLR) in code that checks to see if the executable has the appropriate PE32 file header and .NET header present in the managed assembly. Clearly not applicable here.

However, the CLR is interested in the app.exe.config file at a very early stage in the boot phase. Elements of type <supportedRuntime> must be parsed before the start of the CLR. Obviously, this code is unhappy with the empty .config file. The CLR code is so cool, it never does "let you stumble in any way."

+7
source

Source: https://habr.com/ru/post/892797/


All Articles