I am using some external code which when called with certain parameters throws an exception which can be ignored. Unfortunately I can not change this external code for various reasons.
I have created a wrapper method which looks something like this:
[DebuggerStepThrough]
public static bool TryGetXXX(string input, out string output)
{
try
{
output = MethodThatSometimesFails(input);
return true;
}
catch
{
output = null;
return false;
}
}
private static string MethodThatSometimesFails(string input)
{
// Don't want this to cause a break
// but can not put the attribute on this method
throw new Exception("couldnt deal with your request");
}
Unfortunately though, the external code will still break at the exception inside MethodThatSometimesFails
. The [DebuggerStepThrough]
will only avoid debugging the code above, but the called code will still throw.
What I would like is that the code just runs even with all of check boxes on the "Exceptions..." window checked. Is there an attribute which can do this?
If there is no attribute I could create a project containing these classes / methods and exclude the entire project. Is there a way to do this?
Couldn't find a solution for this. In the end the only option was to put the TryGet into another DLL!