R
Roman Muntyanu
Hi all,
I created object of MyClass : ISomeInterface
Then I created object of this class using reflection mechanism.
ISomeInterface instance =
(ISomeInterface)constructorInfo.Invoke(new Object [0]);
This casting works fine. But When I try
MyClass instance1 = (MyClass)constructorInfo.Invoke(new Object [0]);
I'm getting "Specified cast is not valid" exception.
I tried such an experiment
ISomeInterface instance2 = new MyClass();
MyClass instance1 = (MyClass)instance2;
And this casting works fine. So I found that there is difference how I
created the object of MyClass.
Could someone help to resolve this issue ?
Thank you very much in advance
Roman
I created object of MyClass : ISomeInterface
Then I created object of this class using reflection mechanism.
ISomeInterface instance =
(ISomeInterface)constructorInfo.Invoke(new Object [0]);
This casting works fine. But When I try
MyClass instance1 = (MyClass)constructorInfo.Invoke(new Object [0]);
I'm getting "Specified cast is not valid" exception.
I tried such an experiment
ISomeInterface instance2 = new MyClass();
MyClass instance1 = (MyClass)instance2;
And this casting works fine. So I found that there is difference how I
created the object of MyClass.
Could someone help to resolve this issue ?
Thank you very much in advance
Roman