Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Com MIDL类派生自同一文件中定义的接口_Com_Typelib_Midl - Fatal编程技术网

Com MIDL类派生自同一文件中定义的接口

Com MIDL类派生自同一文件中定义的接口,com,typelib,midl,Com,Typelib,Midl,当我从另一个代理服务器项目中定义的接口派生所述接口时,为什么我不能在idl文件中定义接口,然后让一个CoClass在同一文件中的库块中派生它 [ object, uuid(00000000-0000-0000-0000-000000000000), pointer_default(unique) ] interface IMyInterfaceB: IMyInterfaceA { [id(1), helpstring("")] HRESULT NewMethod(); }

当我从另一个代理服务器项目中定义的接口派生所述接口时,为什么我不能在idl文件中定义接口,然后让一个CoClass在同一文件中的库块中派生它

[
 object,
 uuid(00000000-0000-0000-0000-000000000000),
 pointer_default(unique)
] interface IMyInterfaceB: IMyInterfaceA
{
    [id(1), helpstring("")]
    HRESULT NewMethod();
}

[
 uuid(10000000-0000-0000-0000-000000000000),
 helpstring("Type Library 1.00"),
 version(1.00)
]
library MyLibrary
{
    importlib("stdole32.tlb");
    importlib("stdole2.tlb");

    [
        uuid(20000000-0000-0000-0000-000000000001),
        helpstring("My Class")
    ]
    coclass CMyClass
    {
        interface IMyInterfaceA;
        //interface IMyInterfaceB; /* error when I remove rem */
    };

}

1> midl\oleaut32.dll:错误MIDL2020:生成类型库时出错:布局失败:IMyInterfaceB(0x800288C6

正如Hans Passant指出的,我不应该选择GUID,应该使用生成器来生成它们。虽然这不是问题所在,但本质上是相似的。我在定义接口时没有遵循正确的ID模式,因为到目前为止它并不重要

我想我将重新阅读微软.NET下的COM编程中的相应章节。我在第一次尝试错误查找工具时找到了原因,通过打开Visual Studio高级模式功能暴露了它的存在

经验教训:/


BekaD:

您需要在基本接口和继承接口中使用不同的
id
属性值。

用户“vpp”我刚刚在尝试创建一个从另一个继承的新接口时遇到了这个错误,因此我可以重载其中一个方法。我从原始接口复制并粘贴了整个内容,但没有将“id(1)”部分更改为新的唯一编号,所以我也收到了“error MIDL2020:生成类型库时出错:布局失败”

无需重新创建。IMyInterfaceA声明缺失,因此很难重新创建错误。[source]属性几乎肯定是错误的,仅用于生成事件的DispInterface。如果需要,则需要声明其中一个[default].不要选择自己的GUID,使用guidgen。exe@HansPassant上面的代码是通用垃圾…我不选择GUID…我将删除[source]并知道[source,default]…我分离了代理和对象,当我在库块中提到从IUnknown以外派生的接口时,我发现仍然存在错误:/Post代码实际上再现了该问题。它在我派生的另一个项目中也可以正常工作IStorage@HansPassant无论我叫它IMyInterfaceA还是my,代码都是一样的自己的代码…如果没有理由它不工作,我将不得不一直盯着它看:/