static void BasicTest02() { try { ///※ 必需回傳 dynamic 才能有效觸發KingAOP。 dynamic biz = new MyBusinessClass2(); MyFormData formData = biz.QryFormData("Foo", 987, true); Console.WriteLine(); if (formData == null) { Console.WriteLine("\r\n無資料無法存檔。"); } biz.SaveFormData(formData); Console.WriteLine("\r\n執行完成。"); } catch (Exception ex) { Console.WriteLine("\r\n執行失敗!" + ex.Message); } Console.WriteLine("Press any key to continue."); Console.ReadKey(); }
public void SaveFormData(MyFormData formData) { Console.WriteLine("Step 1"); Console.WriteLine("Step 2"); throw new ApplicationException("例外測試"); Console.WriteLine("Step 3"); }