"Max" <ma******@yahoo.com> wrote in message
news:eX**************@TK2MSFTNGP15.phx.gbl...
I am using late binding to automate my code to Microsoft Outlook and I'm
getting an error in my code:
- Type objClassType = Type.GetTypeFromProgID("Outlook.Application");
- objApp_Late = Activator.CreateInstance(objClassType);
- objInspectors_Late = objApp_Late.GetType().InvokeMember("Inspectors",
- BindingFlags.InvokeMethod, null, objApp_Late, null);
- e_InspectorNewEvent_Late =
- objInspectors_Late.GetType().GetEvent("NewInspector");
-
At this point e_InspectorNewEvent_Late is null. Can someone tell me why
the last line of code does not return an EventInfo?
This is simply not possible using late binding.
COM objects that enter the CLR that don't support IProvideClassInfo or do
not have any interop assembly registered will be wrapped in a generic type
'System.__ComObject'. That means that
objInspectors_Late.GetType().GetEvent("NewInspecto r");
will return null as objInspectors_Late, which is of type __ComObject, does
not "expose" the 'NewInspector' event.
Willy.