10
Answers

VC# 2008 interop code not working on VC# 2010

Andy Webster

Andy Webster

13y
12.5k
1
Hi

I am using VS 2010 Express and have ported some code proven in VS 2008 but it fails in VS 2010 and I cannot understand why.

The code uses InvokeMember:

<object>.Interface.GetType().InvokeMember("<Method Name>",
                                System.Reflection.BindingFlags.InvokeMethod,
                                null, <Object>.Interface, new object[] { <params> });

It works fine in VS 2008 but not in VS 2010, exception thrown is "Value does not fall within the expected range." The code and references are identical, the <object> is not null.

Baffled.

Any ideas?
Answers (10)