System.BadImageFormatException.ToString C# (CSharp) Method

ToString() public method

public ToString ( ) : String
return String
        public override String ToString()
        {
            String s = GetType().FullName + ": " + Message;

            if (_fileName != null && _fileName.Length != 0)
                s += Environment.NewLine + String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("IO.FileName_Name"), _fileName);
            
            if (InnerException != null)
                s = s + " ---> " + InnerException.ToString();

            if (StackTrace != null)
                s += Environment.NewLine + StackTrace;

            try
            {
                if(FusionLog!=null)
                {
                    if (s==null)
                        s=" ";
                    s+=Environment.NewLine;
                    s+=Environment.NewLine;
                    s+=FusionLog;
                }
            }
            catch(SecurityException)
            {
            
            }

            return s;
        }

Usage Example

		public void Constructor2 ()
		{
			BadImageFormatException bif = new BadImageFormatException ("message");

#if NET_2_0
			Assert.IsNotNull (bif.Data, "#1");
#endif
			Assert.IsNull (bif.FileName, "#2");
			Assert.IsNull (bif.InnerException, "#3");
			Assert.IsNotNull (bif.Message, "#4");
			Assert.AreEqual ("message", bif.Message, "#5");
			Assert.IsNull (bif.FusionLog, "#6");
#if TARGET_JVM // ToString always has a stack trace under TARGET_JVM
			Assert.IsTrue (bif.ToString ().StartsWith (bif.GetType ().FullName + ": message"), "#7");
#else
			Assert.AreEqual (bif.GetType ().FullName + ": message",
				bif.ToString (), "#7");
#endif // TARGET_JVM
		}
All Usage Examples Of System.BadImageFormatException::ToString