Queryinterface XXXX Failed When Loading Enterprise Serviced Components

zhaozj2021-02-16  55

COM 1.5 can be said to be a temporary replacement product before Indigo, and COM Service is basically unmanaged code, just like an article inside MSDN Magazine, COM is: Complex Architecture where there is are number place, where the managed code Interacts with unmanaged code - Some Document, Others undocumented.

The symptom of the problem is such that this exception is thrown when loading a COM component that inherits a custom interface, or prompts the "XXX interface is not implemented".

It can be said that 80% of the 80% of COM is related to COM Interop, this problem is no exception. If you change the component's activation method to library, everything is normal. The reason is that the Enterprise Component is directly called COM API directly using Managed C Assembly, and the Enterprise Component outside the process uses RCW (Runtime Call Wrapper) to implement the same COM API. INTEROP, the problem is also on the interop.

First of all, COM Component is possible by UNMANAGED Client, in order to support this call, we generate Class Interface, which supports iDispath, which cannot support Early Binding by specifying [ClassInterface (ClassInterFactype.Autodispatch], which can not support Early Binding, but Well to avoid the unmanaged client from working hard because the interfab method is changed. More information about this can be referred to the INTROTUCING TOTETER INTERFACE topic inside .NET Framework Document.

Second, in order to ensure that the inherited custom interface is possible, it is necessary to specify the Class Interface mode of the interface. The default is to generate the Dual Interface, but in order to adapt to the COM Component interface generation. You also need to add [InterfaTypeAttribute (CominterFaceType.Interfaceisidispatch], telling TLBEXP.EXE this interface will be generated in iDispatch.

The code looks like this:

[InterfaceTypeAttribute (CominterFaceType.Interfaceisidispatch)] public intface ifoo {void foo ();

[Transaction (Transaction (TransactionOption.Required)] Public Foocomponent, ifoo {..............} Basically solved this problem through this setting. .

转载请注明原文地址:https://www.9cbs.com/read-20996.html

New Post(0)