I came across a slightly strange (IMO) code that behaves inconsistently.
try
{
if (helperMethod())
{
return 0;
}
return 0;
}
catch(Exception e)
{
}
finally
{
}
This sits inside a method that is called by VBA by passing a COM object to my DLL. When it only starts, I don't get an exception in C #, but I get a VBA exception.
When I run this in debugging, I get no exception anywhere.
My guess is that the logic in the finally clause takes second place to run, and at that time 0 is already returned by the main theme of the method.
I can rewrite this in several ways, but I don’t know if writing code this way is enough ...?
thank
EDIT: Is it possible that a COM object will be released when I return 0? In this case, it is no longer available in the finally clause.
user338195