diff options
Diffstat (limited to 'src/mscorlib/src/System/BadImageFormatException.cs')
-rw-r--r-- | src/mscorlib/src/System/BadImageFormatException.cs | 87 |
1 files changed, 48 insertions, 39 deletions
diff --git a/src/mscorlib/src/System/BadImageFormatException.cs b/src/mscorlib/src/System/BadImageFormatException.cs index 51a6c40771..42005cccce 100644 --- a/src/mscorlib/src/System/BadImageFormatException.cs +++ b/src/mscorlib/src/System/BadImageFormatException.cs @@ -11,8 +11,8 @@ ** ===========================================================*/ -namespace System { - +namespace System +{ using System; using System.Runtime.Serialization; using FileLoadException = System.IO.FileLoadException; @@ -20,41 +20,46 @@ namespace System { using System.Globalization; [Serializable] - public class BadImageFormatException : SystemException { - + public class BadImageFormatException : SystemException + { private String _fileName; // The name of the corrupt PE file. private String _fusionLog; // fusion log (when applicable) - public BadImageFormatException() - : base(Environment.GetResourceString("Arg_BadImageFormatException")) { - SetErrorCode(__HResults.COR_E_BADIMAGEFORMAT); + public BadImageFormatException() + : base(SR.Arg_BadImageFormatException) + { + HResult = __HResults.COR_E_BADIMAGEFORMAT; } - - public BadImageFormatException(String message) - : base(message) { - SetErrorCode(__HResults.COR_E_BADIMAGEFORMAT); + + public BadImageFormatException(String message) + : base(message) + { + HResult = __HResults.COR_E_BADIMAGEFORMAT; } - - public BadImageFormatException(String message, Exception inner) - : base(message, inner) { - SetErrorCode(__HResults.COR_E_BADIMAGEFORMAT); + + public BadImageFormatException(String message, Exception inner) + : base(message, inner) + { + HResult = __HResults.COR_E_BADIMAGEFORMAT; } public BadImageFormatException(String message, String fileName) : base(message) { - SetErrorCode(__HResults.COR_E_BADIMAGEFORMAT); + HResult = __HResults.COR_E_BADIMAGEFORMAT; _fileName = fileName; } - public BadImageFormatException(String message, String fileName, Exception inner) - : base(message, inner) { - SetErrorCode(__HResults.COR_E_BADIMAGEFORMAT); + public BadImageFormatException(String message, String fileName, Exception inner) + : base(message, inner) + { + HResult = __HResults.COR_E_BADIMAGEFORMAT; _fileName = fileName; } public override String Message { - get { + get + { SetMessageField(); return _message; } @@ -62,17 +67,19 @@ namespace System { private void SetMessageField() { - if (_message == null) { + if (_message == null) + { if ((_fileName == null) && (HResult == System.__HResults.COR_E_EXCEPTION)) - _message = Environment.GetResourceString("Arg_BadImageFormatException"); + _message = SR.Arg_BadImageFormatException; else _message = FileLoadException.FormatFileLoadExceptionMessage(_fileName, HResult); } } - public String FileName { + public String FileName + { get { return _fileName; } } @@ -81,8 +88,8 @@ namespace System { String s = GetType().FullName + ": " + Message; if (_fileName != null && _fileName.Length != 0) - s += Environment.NewLine + Environment.GetResourceString("IO.FileName_Name", _fileName); - + s += Environment.NewLine + SR.Format(SR.IO_FileName_Name, _fileName); + if (InnerException != null) s = s + " ---> " + InnerException.ToString(); @@ -90,23 +97,23 @@ namespace System { s += Environment.NewLine + StackTrace; try { - if(FusionLog!=null) + if (FusionLog != null) { - if (s==null) - s=" "; - s+=Environment.NewLine; - s+=Environment.NewLine; - s+=FusionLog; + if (s == null) + s = " "; + s += Environment.NewLine; + s += Environment.NewLine; + s += FusionLog; } } - catch(SecurityException) + catch (SecurityException) { - } return s; } - protected BadImageFormatException(SerializationInfo info, StreamingContext context) : base(info, context) { + protected BadImageFormatException(SerializationInfo info, StreamingContext context) : base(info, context) + { // Base class constructor will check info != null. _fileName = info.GetString("BadImageFormat_FileName"); @@ -114,7 +121,7 @@ namespace System { { _fusionLog = info.GetString("BadImageFormat_FusionLog"); } - catch + catch { _fusionLog = null; } @@ -123,19 +130,21 @@ namespace System { private BadImageFormatException(String fileName, String fusionLog, int hResult) : base(null) { - SetErrorCode(hResult); + HResult = hResult; _fileName = fileName; - _fusionLog=fusionLog; + _fusionLog = fusionLog; SetMessageField(); } - public String FusionLog { + public String FusionLog + { #pragma warning disable CS0618 // Type or member is obsolete #pragma warning restore CS0618 // Type or member is obsolete get { return _fusionLog; } } - public override void GetObjectData(SerializationInfo info, StreamingContext context) { + public override void GetObjectData(SerializationInfo info, StreamingContext context) + { // Serialize data for our base classes. base will verify info != null. base.GetObjectData(info, context); |