import "oaidl.idl";
import "ocidl.idl";[
object,
uuid(464adae8-6c3f-4c17-9a79-46c5221daba6),
dual,
helpstring("IATLConPropertyVisitor Interface"),
pointer_default(unique)
]interface IATLConPropertyVisitor : IDispatch
{
[propput,  helpstring("Set the interface to browse")]
HRESULT Dispatch([in]IDispatch* pDispatch);
[propget,  helpstring("Get the interface being browsed")]
HRESULT Dispatch([out,retval]IDispatch** ppDispatch);
};[
uuid(b5265b2a-509b-456c-b968-cf14a51cb142),
version(1.0),
helpstring("ATLContainer 1.0 Type Library")
]
library ATLCONTAINERLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb"); [
uuid(b04f638e-5836-415e-90e4-25ae70efc06a),
helpstring("ATLConPropertyVisitor Class")
]
coclass ATLConPropertyVisitor
{
[default] interface IATLConPropertyVisitor;
};
};error MIDL2311 : statements outside library block are illegal in mktyplib compatability mode : [ Interface 'IATLConPropertyVisitor'  ]
error MIDL2096 : duplicated attribute : [helpstring] [ Interface 'IATLConPropertyVisitor'  ]
error MIDL2096 : duplicated attribute : [uuid] [ Interface 'IATLConPropertyVisitor'  ]
Error executing midl.exe.

解决方案 »

  1.   

    用MIDL命令行编译是不会出错的
      

  2.   

    [
    object,
    uuid(464adae8-6c3f-4c17-9a79-46c5221daba6),
    dual,
    helpstring("IATLConPropertyVisitor Interface"),
    pointer_default(unique)
    ]interface IATLConPropertyVisitor : IDispatch
    {
    [propput,  helpstring("Set the interface to browse")]
    HRESULT Dispatch([in]IDispatch* pDispatch);
    [propget,  helpstring("Get the interface being browsed")]
    HRESULT Dispatch([out,retval]IDispatch** ppDispatch);
    };把上面的部分放到 library ATLCONTAINERLib 里面来试试。
      

  3.   

    代码是手工加进去的,为什么不行呢?(本来想在工程里直接加一个atl控件,但想使用向导时,VC报错)把这个接口定义放到Library里面是什么意思?这样MIDL这一关都通不过了.