public void Constructor3_Message_Null() { ArithmeticException ame = new ArithmeticException("something"); FileNotFoundException fnf = new FileNotFoundException((string)null, ame); #if NET_2_0 Assert.IsNotNull(fnf.Data, "#1"); #endif Assert.IsNull(fnf.FileName, "#2"); Assert.IsNotNull(fnf.InnerException, "#3"); Assert.AreSame(ame, fnf.InnerException, "#4"); #if NET_2_0 Assert.IsNull(fnf.Message, "#5"); #else Assert.IsNotNull(fnf.Message, "#5"); // File or assembly name (null), or ... #endif Assert.IsNull(fnf.FusionLog, "#6"); #if NET_2_0 Assert.AreEqual(fnf.GetType().FullName + ": ---> " + ame.GetType().FullName + ": something", fnf.ToString(), "#7"); #else Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName), "#7"); Assert.IsFalse(fnf.ToString().IndexOf(Environment.NewLine) != -1, "#9"); #endif }
public void Constructor4_Message_Empty() { FileNotFoundException fnf = null; fnf = new FileNotFoundException(string.Empty, "file.txt"); #if NET_2_0 Assert.IsNotNull(fnf.Data, "#1"); #endif Assert.IsNotNull(fnf.FileName, "#2"); Assert.AreEqual("file.txt", fnf.FileName, "#3"); Assert.IsNull(fnf.InnerException, "#4"); Assert.IsNotNull(fnf.Message, "#5"); Assert.AreEqual(string.Empty, fnf.Message, "#6"); Assert.IsNull(fnf.FusionLog, "#7"); Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName + ": " + Environment.NewLine), "#8"); #if NET_2_0 Assert.IsTrue(fnf.ToString().IndexOf("'file.txt'") != -1, "#9"); Assert.IsFalse(fnf.ToString().IndexOf("\"file.txt\"") != -1, "#10"); #else Assert.IsFalse(fnf.ToString().IndexOf("'file.txt'") != -1, "#9"); Assert.IsTrue(fnf.ToString().IndexOf("\"file.txt\"") != -1, "#10"); #endif }
public void Constructor4_Message_Null() { FileNotFoundException fnf = null; fnf = new FileNotFoundException((string)null, "file.txt"); Assert.IsNotNull(fnf.Data, "#A1"); Assert.IsNotNull(fnf.FileName, "#A2"); Assert.AreEqual("file.txt", fnf.FileName, "#A3"); Assert.IsNull(fnf.InnerException, "#A4"); Assert.IsNotNull(fnf.Message, "#A5"); Assert.IsNull(fnf.FusionLog, "#A6"); Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName + ": "), "#A7"); Assert.IsTrue(fnf.ToString().IndexOf(Environment.NewLine) != -1, "#A8"); Assert.IsTrue(fnf.ToString().IndexOf("'file.txt'") != -1, "#A9"); Assert.IsFalse(fnf.ToString().IndexOf("\"file.txt\"") != -1, "#A10"); fnf = new FileNotFoundException((string)null, string.Empty); Assert.IsNotNull(fnf.Data, "#B1"); Assert.IsNotNull(fnf.FileName, "#B2"); Assert.AreEqual(string.Empty, fnf.FileName, "#B3"); Assert.IsNull(fnf.InnerException, "#B4"); // .NET 1.1: File or assembly name , or one of its dependencies ... // .NET 2.0: Could not load file or assembly '' or one of its ... Assert.IsNotNull(fnf.Message, "#B5"); Assert.IsNull(fnf.FusionLog, "#B6"); Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName + ": "), "#B7"); Assert.IsFalse(fnf.ToString().IndexOf(Environment.NewLine) != -1, "#B8"); Assert.IsTrue(fnf.ToString().IndexOf("''") != -1, "#B9"); }
public void Constructor4_FileNameAndMessage_Null() { FileNotFoundException fnf = new FileNotFoundException((string)null, (string)null); Assert.IsNotNull(fnf.Data, "#1"); Assert.IsNull(fnf.FileName, "#2"); Assert.IsNull(fnf.InnerException, "#3"); Assert.IsNull(fnf.Message, "#4"); Assert.IsNull(fnf.FusionLog, "#5"); Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName + ": "), "#6"); Assert.IsFalse(fnf.ToString().IndexOf(Environment.NewLine) != -1, "#7"); Assert.IsFalse(fnf.ToString().IndexOf("''") != -1, "#8"); }
public void Constructor4_FileName_Null() { FileNotFoundException fnf = new FileNotFoundException("message", (string)null); Assert.IsNotNull(fnf.Data, "#A1"); Assert.IsNull(fnf.FileName, "#A2"); Assert.IsNull(fnf.InnerException, "#A3"); Assert.IsNotNull(fnf.Message, "#A4"); Assert.AreEqual("message", fnf.Message, "#A5"); Assert.IsNull(fnf.FusionLog, "#A6"); Assert.AreEqual(fnf.GetType().FullName + ": message", fnf.ToString(), "#A7"); fnf = new FileNotFoundException(string.Empty, (string)null); Assert.IsNotNull(fnf.Data, "#B1"); Assert.IsNull(fnf.FileName, "#B2"); Assert.IsNull(fnf.InnerException, "#B3"); Assert.IsNotNull(fnf.Message, "#B4"); Assert.AreEqual(string.Empty, fnf.Message, "#B5"); Assert.IsNull(fnf.FusionLog, "#B6"); Assert.AreEqual(fnf.GetType().FullName + ": ", fnf.ToString(), "#B7"); }
public void Constructor4() { FileNotFoundException fnf = new FileNotFoundException("message", "file.txt"); Assert.IsNotNull(fnf.Data, "#1"); Assert.IsNotNull(fnf.FileName, "#2"); Assert.AreEqual("file.txt", fnf.FileName, "#3"); Assert.IsNull(fnf.InnerException, "#4"); Assert.IsNotNull(fnf.Message, "#5"); Assert.AreEqual("message", fnf.Message, "#6"); Assert.IsNull(fnf.FusionLog, "#7"); Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName + ": message" + Environment.NewLine), "#8"); Assert.IsTrue(fnf.ToString().IndexOf("'file.txt'") != -1, "#9"); Assert.IsFalse(fnf.ToString().IndexOf("\"file.txt\"") != -1, "#9"); }
public void Constructor2_Message_Empty() { FileNotFoundException fnf = new FileNotFoundException(string.Empty); #if NET_2_0 Assert.IsNotNull(fnf.Data, "#1"); #endif Assert.IsNull(fnf.FileName, "#2"); Assert.IsNull(fnf.InnerException, "#3"); Assert.IsNotNull(fnf.Message, "#4"); Assert.AreEqual(string.Empty, fnf.Message, "#5"); Assert.IsNull(fnf.FusionLog, "#6"); #if TARGET_JVM Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName + ": "), "#7"); #else Assert.AreEqual(fnf.GetType().FullName + ": ", fnf.ToString(), "#7"); #endif }
public void NoRestriction() { FileNotFoundException fle = new FileNotFoundException("message", "filename", new FileNotFoundException("inner message", "inner filename")); Assert.AreEqual("message", fle.Message, "Message"); Assert.AreEqual("filename", fle.FileName, "FileName"); Assert.IsNull(fle.FusionLog, "FusionLog"); Assert.IsNotNull(fle.ToString(), "ToString"); }
public void Constructor1() { FileNotFoundException fnf = new FileNotFoundException(); Assert.IsNotNull(fnf.Data, "#1"); Assert.IsNull(fnf.FileName, "#2"); Assert.IsNull(fnf.InnerException, "#3"); Assert.IsNotNull(fnf.Message, "#4"); // Unable to find the specified file Assert.IsNull(fnf.FusionLog, "#5"); Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName), "#6"); }
public static void ToStringTest() { string message = "this is not the file you're looking for"; string fileName = "file.txt"; var innerException = new Exception("Inner exception"); var exception = new FileNotFoundException(message, fileName, innerException); var toString = exception.ToString(); Assert.Contains(": " + message, toString); Assert.Contains(": '" + fileName + "'", toString); Assert.Contains("---> " + innerException.ToString(), toString); // set the stack trace try { throw exception; } catch { Assert.False(string.IsNullOrEmpty(exception.StackTrace)); Assert.Contains(exception.StackTrace, exception.ToString()); } }
public void FullRestriction() { FileNotFoundException fle = new FileNotFoundException("message", "filename", new FileNotFoundException("inner message", "inner filename")); Assert.AreEqual("message", fle.Message, "Message"); Assert.AreEqual("filename", fle.FileName, "FileName"); Assert.IsNull(fle.FusionLog, "FusionLog"); // ToString doesn't work in this case and strangely throws a FileNotFoundException Assert.IsNotNull(fle.ToString(), "ToString"); }
public static void ToStringTest() { string message = "this is not the file you're looking for"; string fileName = "file.txt"; var innerException = new Exception("Inner exception"); var exception = new FileNotFoundException(message, fileName, innerException); var toString = exception.ToString(); Assert.Contains(": " + message, toString); Assert.Contains(": '" + fileName + "'", toString); Assert.Contains("---> " + innerException.ToString(), toString); // set the stack trace try { throw exception; } catch { Assert.False(string.IsNullOrEmpty(exception.StackTrace)); Assert.Contains(exception.StackTrace, exception.ToString()); } }
public void Constructor2_Message_Null() { FileNotFoundException fnf = new FileNotFoundException((string)null); Assert.IsNotNull(fnf.Data, "#1"); Assert.IsNull(fnf.FileName, "#2"); Assert.IsNull(fnf.InnerException, "#3"); Assert.IsNull(fnf.Message, "#4"); Assert.IsNull(fnf.FusionLog, "#5"); Assert.AreEqual(fnf.GetType().FullName + ": ", fnf.ToString(), "#6"); }
public void Constructor2_Message_Null() { FileNotFoundException fnf = new FileNotFoundException((string)null); #if NET_2_0 Assert.IsNotNull(fnf.Data, "#1"); #endif Assert.IsNull(fnf.FileName, "#2"); Assert.IsNull(fnf.InnerException, "#3"); #if NET_2_0 Assert.IsNull(fnf.Message, "#4"); #else Assert.IsNotNull(fnf.Message, "#4"); // File or assembly name (null), or ... #endif Assert.IsNull(fnf.FusionLog, "#5"); #if NET_2_0 Assert.AreEqual(fnf.GetType().FullName + ": ", fnf.ToString(), "#6"); #else Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName), "#6"); #endif }
public void Constructor3_Message_Empty() { ArithmeticException ame = new ArithmeticException("something"); FileNotFoundException fnf = new FileNotFoundException(string.Empty, ame); #if NET_2_0 Assert.IsNotNull(fnf.Data, "#1"); #endif Assert.IsNull(fnf.FileName, "#2"); Assert.IsNotNull(fnf.InnerException, "#3"); Assert.AreSame(ame, fnf.InnerException, "#4"); Assert.IsNotNull(fnf.Message, "#5"); Assert.AreEqual(string.Empty, fnf.Message, "#6"); Assert.IsNull(fnf.FusionLog, "#7"); #if TARGET_JVM Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName + ": ---> " + ame.GetType().FullName + ": something"), "#8"); #else Assert.AreEqual(fnf.GetType().FullName + ": ---> " + ame.GetType().FullName + ": something", fnf.ToString(), "#8"); #endif }
public void Constructor4_FileNameAndMessage_Empty() { FileNotFoundException fnf = new FileNotFoundException(string.Empty, string.Empty); Assert.IsNotNull(fnf.Data, "#1"); Assert.IsNotNull(fnf.FileName, "#2"); Assert.AreEqual(string.Empty, fnf.FileName, "#3"); Assert.IsNull(fnf.InnerException, "#4"); Assert.IsNotNull(fnf.Message, "#5"); Assert.AreEqual(string.Empty, fnf.Message, "#6"); Assert.IsNull(fnf.FusionLog, "#7"); Assert.AreEqual(fnf.GetType().FullName + ": ", fnf.ToString(), "#8"); }
public void Constructor3_Message_Null() { ArithmeticException ame = new ArithmeticException("something"); FileNotFoundException fnf = new FileNotFoundException((string)null, ame); Assert.IsNotNull(fnf.Data, "#1"); Assert.IsNull(fnf.FileName, "#2"); Assert.IsNotNull(fnf.InnerException, "#3"); Assert.AreSame(ame, fnf.InnerException, "#4"); Assert.IsNull(fnf.Message, "#5"); Assert.IsNull(fnf.FusionLog, "#6"); Assert.AreEqual(fnf.GetType().FullName + ": ---> " + ame.GetType().FullName + ": something", fnf.ToString(), "#7"); }
public void Constructor4_FileName_Null() { FileNotFoundException fnf = new FileNotFoundException("message", (string)null); #if NET_2_0 Assert.IsNotNull(fnf.Data, "#A1"); #endif Assert.IsNull(fnf.FileName, "#A2"); Assert.IsNull(fnf.InnerException, "#A3"); Assert.IsNotNull(fnf.Message, "#A4"); Assert.AreEqual("message", fnf.Message, "#A5"); Assert.IsNull(fnf.FusionLog, "#A6"); #if TARGET_JVM Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName + ": message"), "#A7"); #else Assert.AreEqual(fnf.GetType().FullName + ": message", fnf.ToString(), "#A7"); #endif fnf = new FileNotFoundException(string.Empty, (string)null); #if NET_2_0 Assert.IsNotNull(fnf.Data, "#B1"); #endif Assert.IsNull(fnf.FileName, "#B2"); Assert.IsNull(fnf.InnerException, "#B3"); Assert.IsNotNull(fnf.Message, "#B4"); Assert.AreEqual(string.Empty, fnf.Message, "#B5"); Assert.IsNull(fnf.FusionLog, "#B6"); #if TARGET_JVM Assert.IsTrue(fnf.ToString().StartsWith(fnf.GetType().FullName + ": "), "#B7"); #else Assert.AreEqual(fnf.GetType().FullName + ": ", fnf.ToString(), "#B7"); #endif }
public void Constructor2() { FileNotFoundException fnf = new FileNotFoundException("message"); #if NET_2_0 Assert.IsNotNull(fnf.Data, "#1"); #endif Assert.IsNull(fnf.FileName, "#2"); Assert.IsNull(fnf.InnerException, "#3"); Assert.IsNotNull(fnf.Message, "#4"); Assert.AreEqual("message", fnf.Message, "#5"); Assert.IsNull(fnf.FusionLog, "#6"); Assert.AreEqual(fnf.GetType().FullName + ": message", fnf.ToString(), "#7"); }
public string ReadText() { if (File.Exists(Path)) { var text = File.ReadAllText(Path, Encoding.UTF8); text = Replacement(text); text = FormateText(text); text = Replacement(text); return(text); } var ex = new FileNotFoundException("File not found"); Console.WriteLine(ex.ToString()); Environment.Exit(0); return(null); }
static void Main(string[] args) { //if args != 0 CS_ref1_HeightMap.exe input(.hgt) output(.bmp) ElevationTreshold(int) try { //check if args are given if (args.Length == 0) { Console.WriteLine("Input file (.hgt): "); string input = Console.ReadLine(); Console.WriteLine("Elevation Threshold (integer): "); int threshold = int.Parse(Console.ReadLine()); Console.WriteLine("Output file (.bmp): "); string output = Console.ReadLine(); HeightMap hm = HeightMap.Parse(input); hm.ElevationThreshold = threshold; hm.SaveToBitmap(output); } else if (args.Length != 0) { HeightMap hm = HeightMap.Parse(args[0]); hm.ElevationThreshold = int.Parse(args[2]); hm.SaveToBitmap(args[1]); } else { Console.WriteLine("Error!\n"); Console.ReadLine(); } } catch { //invalid file name(s) FileNotFoundException ex = new FileNotFoundException(); Console.WriteLine(ex.ToString()); Console.ReadLine(); } }
public void startSerialization(string inputFilePath, string outputFilePath, string outputType) { var inputFile = new FileInfo(inputFilePath); if (!inputFile.Exists) { var e = new FileNotFoundException("Plik " + inputFilePath + " nie istnieje"); Logger.Log(e.ToString()); throw e; } var stream = new StreamReader(inputFile.OpenRead()); string line = null; List <Student> students = new List <Student>(); List <AktywneStudia> studies = new List <AktywneStudia>(); while ((line = stream.ReadLine()) != null) { string[] row = line.Split(','); if (row.Length != 9) { Logger.Log("Invalid row: " + line); continue; } else { Boolean isDataValid = true; foreach (string val in row) { if (val.Trim() == "") { Logger.Log("Invalid row: " + line); isDataValid = false; break; } } if (!isDataValid) { continue; } } Boolean isDupli = false; foreach (var stud in students) { if (stud.NumerIndeksu == 's' + row[4] && stud.Imie == row[0] && stud.Nazwisko == row[1]) { Logger.Log("Duplicate row: " + line); isDupli = true; break; } } if (!isDupli) { students.Add(new Student(row)); if (studies.Count < 1) { studies.Add(new AktywneStudia(row[2], 1)); } else { Boolean found = false; foreach (var study in studies) { if (study.Kierunek == row[2]) { study.LiczbaStudentow++; found = true; break; } } if (!found) { studies.Add(new AktywneStudia(row[2], 1)); } } } } stream.Dispose(); switch (outputType.ToLower()) { case "xml": FileGenerator.createXml(students, studies, outputFilePath); break; case "json:": FileGenerator.createJSON(students, studies, outputFilePath); break; default: break; } }
static int Main () { FileNotFoundException fnf = null; fnf = new FileNotFoundException (); if (fnf.Message != "Unable to find the specified file.") { Console.WriteLine ("#A1:" + fnf.Message); return 1; } if (fnf.ToString () != "System.IO.FileNotFoundException: Unable to find the specified file.") { Console.WriteLine ("#A2: " + fnf.ToString ()); return 1; } fnf = new FileNotFoundException ("message"); if (fnf.Message != "message") { Console.WriteLine ("#B1:" + fnf.Message); return 1; } if (fnf.ToString () != "System.IO.FileNotFoundException: message") { Console.WriteLine ("#B2: " + fnf.ToString ()); return 1; } fnf = new FileNotFoundException ("message", new ArithmeticException ()); if (fnf.Message != "message") { Console.WriteLine ("#C1:" + fnf.Message); return 1; } if (fnf.ToString () != "System.IO.FileNotFoundException: message ---> System.ArithmeticException: Overflow or underflow in the arithmetic operation.") { Console.WriteLine ("#C2: " + fnf.ToString ()); return 1; } fnf = new FileNotFoundException ("message", "file.txt"); if (fnf.Message != "message") { Console.WriteLine ("#D1:" + fnf.Message); return 1; } #if NET_2_0 if (fnf.ToString () != ("System.IO.FileNotFoundException: message" + Environment.NewLine + "File name: 'file.txt'")) { #else if (fnf.ToString () != ("System.IO.FileNotFoundException: message" + Environment.NewLine + "File name: \"file.txt\"")) { #endif Console.WriteLine ("#D2: " + fnf.ToString ()); return 1; } fnf = new FileNotFoundException ("message", "file.txt", new ArithmeticException ()); if (fnf.Message != "message") { Console.WriteLine ("#E1"); return 1; } #if NET_2_0 if (fnf.ToString () != ("System.IO.FileNotFoundException: message" + Environment.NewLine + "File name: 'file.txt' ---> System.ArithmeticException: Overflow or underflow in the arithmetic operation.")) { #else if (fnf.ToString () != ("System.IO.FileNotFoundException: message" + Environment.NewLine + "File name: \"file.txt\" ---> System.ArithmeticException: Overflow or underflow in the arithmetic operation.")) { #endif Console.WriteLine ("#E2: " + fnf.ToString ()); return 1; } fnf = new FileNotFoundException (null); #if NET_2_0 if (fnf.Message != null) { #else if (fnf.Message != "File or assembly name (null), or one of its dependencies, was not found.") { #endif Console.WriteLine ("#F1:" + fnf.Message); return 1; } #if NET_2_0 if (fnf.ToString () != "System.IO.FileNotFoundException: ") { #else if (fnf.ToString () != "System.IO.FileNotFoundException: File or assembly name (null), or one of its dependencies, was not found.") { #endif Console.WriteLine ("#F2"); return 1; } fnf = new FileNotFoundException (null, "file.txt"); #if NET_2_0 if (fnf.Message != "Could not load file or assembly 'file.txt' or one of its dependencies. The system cannot find the file specified.") { #else if (fnf.Message != "File or assembly name file.txt, or one of its dependencies, was not found.") { #endif Console.WriteLine ("#G1: " + fnf.Message); return 1; } #if NET_2_0 if (fnf.ToString () != ("System.IO.FileNotFoundException: Could not load file or assembly 'file.txt' or one of its dependencies. The system cannot find the file specified." + Environment.NewLine + "File name: 'file.txt'")) { #else if (fnf.ToString () != ("System.IO.FileNotFoundException: File or assembly name file.txt, or one of its dependencies, was not found." + Environment.NewLine + "File name: \"file.txt\"")) { #endif Console.WriteLine ("#G2: " + fnf.ToString ()); return 1; } fnf = new FileNotFoundException (null, (string) null); #if NET_2_0 if (fnf.Message != null) { #else if (fnf.Message != "File or assembly name (null), or one of its dependencies, was not found.") { #endif Console.WriteLine ("#H1: " + fnf.Message); return 1; } #if NET_2_0 if (fnf.ToString () != "System.IO.FileNotFoundException: ") { #else if (fnf.ToString () != "System.IO.FileNotFoundException: File or assembly name (null), or one of its dependencies, was not found.") { #endif Console.WriteLine ("#H2: " + fnf.ToString ()); return 1; } fnf = new FileNotFoundException (null, string.Empty); #if NET_2_0 if (fnf.Message != "Could not load file or assembly '' or one of its dependencies. The system cannot find the file specified.") { #else if (fnf.Message != "File or assembly name , or one of its dependencies, was not found.") { #endif Console.WriteLine ("#I1: " + fnf.Message); return 1; } #if NET_2_0 if (fnf.ToString () != "System.IO.FileNotFoundException: Could not load file or assembly '' or one of its dependencies. The system cannot find the file specified.") { #else if (fnf.ToString () != "System.IO.FileNotFoundException: File or assembly name , or one of its dependencies, was not found.") { #endif Console.WriteLine ("#I2: " + fnf.ToString ()); return 1; } fnf = new FileNotFoundException (string.Empty, string.Empty); #if NET_2_0 if (fnf.Message != string.Empty) { #else if (fnf.Message != string.Empty) { #endif Console.WriteLine ("#J1: " + fnf.Message); return 1; } #if NET_2_0 if (fnf.ToString () != "System.IO.FileNotFoundException: ") { #else if (fnf.ToString () != "System.IO.FileNotFoundException: ") { #endif Console.WriteLine ("#J2: " + fnf.ToString ()); return 1; } fnf = new FileNotFoundException (string.Empty, (string) null); #if NET_2_0 if (fnf.Message != string.Empty) { #else if (fnf.Message != string.Empty) { #endif Console.WriteLine ("#K1: " + fnf.Message); return 1; } #if NET_2_0 if (fnf.ToString () != "System.IO.FileNotFoundException: ") { #else if (fnf.ToString () != "System.IO.FileNotFoundException: ") { #endif Console.WriteLine ("#K2: " + fnf.ToString ()); return 1; } try { Assembly.LoadFrom ("b.dll"); return 1; } catch (FileNotFoundException ex) { if (ex.Message == null) { Console.WriteLine ("#L1"); return 1; } #if NET_2_0 if (ex.Message != "Could not load file or assembly 'b.dll' or one of its dependencies. The system cannot find the file specified.") { #else if (ex.Message != "File or assembly name b.dll, or one of its dependencies, was not found.") { #endif Console.WriteLine ("#L2: " + ex.Message); return 1; } if (ex.FileName == null) { Console.WriteLine ("#L3"); return 1; } if (ex.FileName != "b.dll") { Console.WriteLine ("#L4"); return 1; } } try { Assembly.Load ("whatever"); return 1; } catch (FileNotFoundException ex) { if (ex.Message == null) { Console.WriteLine ("#M1"); return 1; } #if NET_2_0 if (ex.Message != "Could not load file or assembly 'whatever' or one of its dependencies. The system cannot find the file specified.") { #else if (ex.Message != "File or assembly name whatever, or one of its dependencies, was not found.") { #endif Console.WriteLine ("#M2: " + ex.Message); return 1; } if (ex.FileName == null) { Console.WriteLine ("#M3"); return 1; } if (ex.FileName != "whatever") { Console.WriteLine ("#M4"); return 1; } } try { AppDomain.CurrentDomain.ExecuteAssembly ("c.dll"); return 1; } catch (FileNotFoundException ex) { if (ex.Message == null) { Console.WriteLine ("#N1"); return 1; } #if NET_2_0 if (ex.Message != "Could not load file or assembly 'c.dll' or one of its dependencies. The system cannot find the file specified.") { #else if (ex.Message != "File or assembly name c.dll, or one of its dependencies, was not found.") { #endif Console.WriteLine ("#N2: " + ex.Message); return 1; } if (ex.FileName == null) { Console.WriteLine ("#N3"); return 1; } if (ex.FileName != "c.dll") { Console.WriteLine ("#N4"); return 1; } } return 0; } }