views:

73

answers:

1

I am trying to select the ChartArea using the Select method through reflection in C#. This is the line of code I am using:

oChartArea.GetType().InvokeMember("Select", BindingFlags.InvokeMethod, null, oChartArea, null);

Here, oChartArea is the ChartArea object.

This works perfectly fine in Vista/Office 2007 but throws exception in XP SP2/ Office 2003. Any suggestions?

A: 

Why are you using reflection?
Couldn't you call oChartArea.Select() directly?

What exception does it throw in Office 2003?

shahkalpesh
I am using reflection to make it compatible with both Excel 2003 and 2007. The exception statement is:"Exception has been thrown by the target of invocation."
danish
You don't need reflection to write code which works with both.
Mathias