I am finding that the methods exposed by an instance of __ComObject
don't match what I expect.
Here is an example that works as expected:
var type = Type.GetTypeFromProgID("Excel.Application");
foreach ( var member in type.GetMembers() )
{
Console.WriteLine(m.Name);
}
If you run this, you'll get a list of the properties and methods exposed by Excel.Application, such as
ActivateMicrosoftApp
ActiveCell
ActiveChart
ActiveDialog
ActiveEncryptionSession
//Etc... there are about 100 methods and properties
However, I have a custom COM component (contained in a third party .exe) where the properties and methods do not match what is expected, nor do they match what is shown in Object Browser. Instead, I get back these:
ToString
GetLifetimeService
InitializeLifetimeService
CreateObjRef
Equals
GetHashCode
GetType
These look like the properties and methods that belong to a MarshalByReferenceObject
. But that isn't what I need-- I can't use it to invoke any of the COM component's methods (if I try, I get back System.Runtime.InteropServices.COMException: Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))
).
What are these methods? Where is my proper ComObject? How do I call the actual methods that belong to the COM component?
Note: If I generate an interop assembly using TlbImp.exe
, I get a .NET proxy class that contains all the proper properties and methods, and I can invoke them and they work.
Aucun commentaire:
Enregistrer un commentaire