سؤال

I'm adding the the Microsoft Enterprise Application Block's "Exception Handling" module to my project. Following thier instructions mnsd MSDN it says I need to add a using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling; statement. Does this need to go in every single file that throws an exception handled by the the block, or just the file that catches the error?

For example, say I've got FormMainView, FormMainPresenter, and Class1, Class2, Class3. FormMainView is the view that calls FormMainPresenter, and that delegates specific tasks to the three classes. Classes 1 -3 throw various exceptions and they're caught in the Presenter. Do all 4 files need this using statement, or just the presenter?

Using the MS EAB 4.1, by the way.

هل كانت مفيدة؟

المحلول

The using statement needs to be in all .cs files that make use of the Exception. Both classes that throw the exceptions and classes that handle the thrown exceptions.

Visual studio will complain when you are missing a using. To double-check your usings you can remove one and see if the compiler complains, if it does then the using is required. If it doesn't complain then the using was redundant.

FormMainView is the view that calls FormMainPresenter, and that delegates specific tasks to the three classes.

Classes 1 -3 throw various exceptions and they're caught in the Presenter.

Do all 4 files need this using statement, or just the presenter?

If Exceptions are caught in FormMainPresenter, FormMainView will not need to know about them so no using is required in FormMainPresenter. A using in the other 4 classes is required.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top