Professional ASP.NET 2.0 Security, Membership, and Role Management phần 7

Vào thời điểm này, phương pháp khởi tạo có thể hoàn thành mà không có lỗi, hoặc bắt bất cứ điều gì ngoại lệ xảy ra. Đối với cả hai trường hợp tính năng đánh dấu là khởi tạo. Trong trường hợp lỗi, nó cũng lưu trữ một tham chiếu đến các ngoại lệ gây ra khởi thất bại. | The Provider Model By this point the Initialize method is able to complete without error or it catches whatever exception occurred. For either case the feature marks itself as being initialized. In the error case it also stores a reference to the exception that caused initialization to fail. This is another point where the providerbased features are a little different than the sample feature. The provider-based features need to store the exception and rethrow it whenever their private initialization methods are called from their public properties and methods. However the sample feature class shown previously instead relies on the Framework to do the heavy lifting. Because Initialize was called from the static constructor the Framework will remember that the static constructor failed. This means if the Initialize method fails subsequent attempts to call public properties or methods on the static feature class result in a being thrown. The InnerException property on this exception instance will represent the true exception that was thrown from inside of the Initialize method. From a programming standpoint either the approach or the approach shown previously that relies on a static constructor is valid. The decision is up to you. Using the static constructor eliminates the need for funky lock logic but you do need to drill into the TypeInitializationException to find the root cause of a failure. The approach means that you will always have the problematic exception being thrown from public APIs and properties. But you will need to use locking inside of your feature s initialization logic and have each public property and method on your feature class call back to your initialization method to cause the initialization exception to be rethrown. At this point let s take a look at the feature s configuration section class. You want a configuration class that provides strongly typed access for a .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.