A first chance exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
I am receiving this error; I know that it is throwing it because of a System.Reflection problem derived from an inheirt class. In psudeo code I have
ClassA
somePropA
somePropB
End class
ClassB
must inherit ClassA
somePropAB
somePropBB
End Class
I create an instance of ClassB
Dim instanceOfB as new ClassB
Then I use System.Reflection to retrieve the Properties.
Dim someProps() = instanceOfB.GetType.GetProperties()
The problem only occurs when I try to reference the ClassA property Info; I am Typing it correctly; so I think the error is wrong; unless VB.NET is somehow doing a temporary conversion which I doubt.
Anyone have any IDEAs what this might be? And how to solve it?
I have tried to CObj the type return as a part of the .GetValue Method that doesn't seem to work.
My problem is slightly complicated because I use the .GetValue Method to retrieve information; and all my properties are indexed.
The specific Inner Exception says the following :
"Exception has been thrown by the target of an invocation."
Does that specifically refer to the ClassB stating it cannot pass back the value because it is technically a different TYPE then ClassA? If that is true; then Inheritance is not working the way I thought it was supposed to.
In my understanding ClassB is the Type, and ClassA is just the type Reference.
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
I am receiving this error; I know that it is throwing it because of a System.Reflection problem derived from an inheirt class. In psudeo code I have
ClassA
somePropA
somePropB
End class
ClassB
must inherit ClassA
somePropAB
somePropBB
End Class
I create an instance of ClassB
Dim instanceOfB as new ClassB
Then I use System.Reflection to retrieve the Properties.
Dim someProps() = instanceOfB.GetType.GetProperties()
The problem only occurs when I try to reference the ClassA property Info; I am Typing it correctly; so I think the error is wrong; unless VB.NET is somehow doing a temporary conversion which I doubt.
Anyone have any IDEAs what this might be? And how to solve it?
I have tried to CObj the type return as a part of the .GetValue Method that doesn't seem to work.
My problem is slightly complicated because I use the .GetValue Method to retrieve information; and all my properties are indexed.
The specific Inner Exception says the following :
"Exception has been thrown by the target of an invocation."
Does that specifically refer to the ClassB stating it cannot pass back the value because it is technically a different TYPE then ClassA? If that is true; then Inheritance is not working the way I thought it was supposed to.
In my understanding ClassB is the Type, and ClassA is just the type Reference.
Last edited: