Rockstart
Rockstart

Reputation: 2377

Enable first chance exceptions for specific piece of code

I need Visual Studio to throw first chance exceptions only for a specific class.

If i enable First Chance exception in Visual Studio, it enables for the entire solution.My solution is big and I do not want the exceptions to be thrown every where.

I want the exceptions to be thrown by Visual studio only for a specific piece of code/module/method.

How do I do that? Are there any attributes that I can use for this? Or is it possible to enable through code?

Upvotes: 1

Views: 91

Answers (1)

Freelancer
Freelancer

Reputation: 9064

As you said >

My solution is big and I do not want the exceptions to be thrown every where.

I want the exceptions to be thrown by Visual studio only for a specific piece of code/module/method.

I will suggest you to use try and catch block for only the piece of code where you want the exception to be thrown by visual studio.

If solution is big, try to open connection only once and at the last point close it.

Upvotes: 1

Related Questions