Requiresnew 37 outline introduction system namespace

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: uot;delete orders", sqlConn); SqlConn.Execute(); } } Automatic Transactions and Framework Class Library Programming Model [Transaction(TransactionOption.Required)] public class Bar() { //. . . } TransactionAttribute Constructor Variations [TransactionAttribute(TransactionOption.NotSupported)] [TransactionAttribute(TransactionOption.Support)] [TransactionAttribute(TransactionOption.Required)] [TransactionAttribute(TransactionOption.RequiresNew)] 37 Outline Introduction System Namespace Collection Classes I/O and Networking Threading and Synchronization Transactions Exceptions Exceptions Introduction The Exception Object Best Practices for Handling Exceptions 38 Exceptions What is an Exception? An exception is any error condition or unexpected behavior encountered by an executing program Exceptions can come from an executing program or from the runtime environment To the runtime, an exception is an object that inherits from the System.Exception class Exceptions The Exception Object An Exception object is an instance of the Exception class, the base class from which all exceptions inherit Properties of the Exception class: The StackTrace property The InnerException property The Message property The HelpLink property 39 Exceptions Best Practices Simple catch and display catch (Exception e) { Console.WriteLine (e); } Catch block order matters Write most specific catch blocks first, then least specific Exceptions Best Practices Using StackTrace with an exception try { Level1(); } catch (Exception e) { StackTrace st = new StackTrace(e, true); Console.WriteLine("Stack Trace:"); for (int i = 0; i < st.FrameCount; i++) { // Display the stack frame… } } 40...
View Full Document

This note was uploaded on 04/04/2014 for the course CS 5950 taught by Professor Staff during the Summer '08 term at Western Michigan.

Ask a homework question - tutors are online