Hi!
I want to know if a certain member function is available in a COM object,
before I try to call it. I'm using late binding and when I know the member
exists, everything is fine. Here's the code:
Type t = Type.GetTypeFromProgID("RR_Ispol.Road");
object o = Activator.CreateInstance(t);
object[] parameters = { @"HzAlignment.txt",
@"HzAlignment.xml" };
Int32 result = (Int32)t.InvokeMember("ImportRoadHz",
BindingFlags.InvokeMethod,
null,
o,
parameters);
If the member ImportRoadHz isn't available in RR_Ispol.Road, a COMException
is thrown. How can I test if the member is there or not, before I try to
call it? Calling it and catching an exception doesn't seem to be the
optimal solution. Oh, I have to use late binding because I don't know the
interface in advance.
Thanks in advance!
--
Daniel