Why does a zero byte app.config file cause a very strange error?
The volume for a file has been externa开发者_开发知识库lly altered so that the opened file is no longer valid.
This is caused when you have an app.config which is zero bytes. The error appears to come from Windows - even WinDBG won't launch it.
I know it's completely invalid to have a zero byte app.config, but what causes this error, where does it come from and why does it happen?
//
// 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 pertinent than the boilerplate error message text. This is not quite unusual. I can see it being used inside the SSCLI20 source code (the open source version of the CLR) in code that checks if the executable has the proper PE32 file header and the .NET header present in a managed assembly. Clearly that doesn't apply here.
Nevertheless, the CLR is interested in the app.exe.config file at a very early moment in the bootstrapping stage. Elements like <supportedRuntime>
must be parsed before the CLR can get started. Clearly this code is not happy with an empty .config file. The CLR code is awesome like that, it never does the 'let's stumble on anyway' cop-out.
精彩评论