C# script (from XML)

  • Thread starter Thread starter Vincent Finn
  • Start date Start date
V

Vincent Finn

Hi,

I have a C# function being called from an XML file

I have hit a problem access a COM component
I use CreateObject to create the object but I can't access its
functions

object tchart = CreateObject("TeeChart.TChart");
tchart.Export();

If I swap to using VB.Net I can do this fine but not in C#

I know this is due to the fact that VB uses late binding and C#
doesn't.

Is there a way of doing this in C#?

Vin
 
Try this...

Type comType = Type.GetTypeFromProgID( "TeeChart.TChart" );
object comObject = Activator.CreateInstance( comType );

You can then use comType.InvokeMember() to call methods on comObject.

Regards,
-Jeff
 
Try this...

Type comType = Type.GetTypeFromProgID( "TeeChart.TChart" );
object comObject = Activator.CreateInstance( comType );

You can then use comType.InvokeMember() to call methods on comObject.

Regards,
-Jeff

Thanks, that works
The continuous calls to InvokeMember are messy though so I'll just
have to swallow my pride and use VB :-(

Thanks anyway, Vin
 
Back
Top