Why do some .Net Exceptions end with newline -


I have a list view that shows an error to the user. Part of this also includes exception messages. The error is also written in a log file.

Now I've noticed that some exception messages end with a new line. File like. Can forward messages (English .NET 3.5 SP1) "The file that does not already exist when it can not create a file. \ R \ n" .

Adding log files to the list view and odd view due to the new line .Trim () solves the problem but there is no reason for the new line.

Source of two exception message text First, mscorlib.dll contains string processing, second format That is generated by Windows by the FormatMessage () API. The error code for your example is 183, ERROR_ALREADY_EXISTS . Mscorlib.dll contains a dedicated string resource for that error:

IO.IO_AlreadyExists_Name = "{0}" can not be created because the file or directory with the same name already exists.

There is no linefeed in the message that creates an exception message (System.IO.WinIOError) first checks that a meaningful file to generate {0} for the entire formatting argument The name is obviously fails in your program, it's a little weird. The fallback format is a Windows error message created by error message () and this resource is not formatted as a string in the form you found.

It can be argued that this is a bug, you can report it on the connector. Microsoft.com will be certain that the odds are zero though. There is some soul that is parsing message assets, especially since it is an IOException. Trimming like you is a good solution.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -