misterstick
Programmer
i use reflection in my code to run forms, getting the class names to create at runtime from data held in a database.
this works pretty well, if not instantly, but my problem comes when the invoked form throws an error.
i'm using the following code:
i can put in catches for the errors thrown by CreateInstance itself, but how to catch "Target of Invocation" errors?
FxCop doesn't like "catch ( Exception ex ) { ... }", should i just use "catch { }" and accept that the form pointer will be null?
what do you think?
mtia,
mr s. <
this works pretty well, if not instantly, but my problem comes when the invoked form throws an error.
i'm using the following code:
Code:
string className = valueFromData;
Form form = this.GetType().Assembly.CreateInstance(className) as Form;
if ( form != null )
{
// do stuff with it
}
i can put in catches for the errors thrown by CreateInstance itself, but how to catch "Target of Invocation" errors?
FxCop doesn't like "catch ( Exception ex ) { ... }", should i just use "catch { }" and accept that the form pointer will be null?
what do you think?
mtia,
mr s. <