// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System.Globalization;
using System.Runtime.Serialization;
using System.Security.Permissions;
+using System.Runtime.InteropServices;
+using System.Text;
namespace System
{
[Serializable]
+ [ComVisible (true)]
public class BadImageFormatException : SystemException
{
const int Result = unchecked ((int)0x8007000B);
// Constructors
public BadImageFormatException ()
- : base (Locale.GetText ("Invalid file image."))
+ : base (Locale.GetText ("Format of the executable (.exe) or library (.dll) is invalid."))
{
HResult = Result;
}
fusionLog = info.GetString ("BadImageFormat_FusionLog");
}
- public BadImageFormatException (string message, Exception innerException)
- : base (message, innerException)
+ public BadImageFormatException (string message, Exception inner)
+ : base (message, inner)
{
HResult = Result;
}
HResult = Result;
}
- public BadImageFormatException (string message, string fileName, Exception innerException)
- : base (message, innerException)
+ public BadImageFormatException (string message, string fileName, Exception inner)
+ : base (message, inner)
{
this.fileName = fileName;
HResult = Result;
// Properties
public override string Message
{
- get { return base.Message; }
+ get {
+ if (base.message == null) {
+ return string.Format (CultureInfo.CurrentCulture,
+ "Could not load file or assembly '{0}' or one of"
+ + " its dependencies. An attempt was made to load"
+ + " a program with an incorrect format.", fileName);
+ }
+ return base.Message;
+ }
}
public string FileName
public override string ToString ()
{
- if (fileName != null)
- return Locale.GetText ("Filename: ") + fileName;
- return base.ToString ();
+ StringBuilder sb = new StringBuilder (GetType ().FullName);
+ sb.AppendFormat (": {0}", Message);
+
+ if (fileName != null && fileName.Length > 0) {
+ sb.Append (Environment.NewLine);
+ sb.AppendFormat ("File name: '{0}'", fileName);
+ }
+
+ if (this.InnerException != null)
+ sb.AppendFormat (" ---> {0}", InnerException);
+
+ if (this.StackTrace != null) {
+ sb.Append (Environment.NewLine);
+ sb.Append (StackTrace);
+ }
+
+ return sb.ToString ();
}
}
}