我用的是vc6。0
1.如果我按照书上的方式在命令行键入:midl server.idl则提示“无法找到mspdb60.dll..." 编译过程终止。在我在机器所有目录下均没找到该DLL2.如果我把server.idl直接放到工程中(我创建了一个IN PROC工程),随工程一起编译链接。idl编译的时候出现如下错误:
Creating Type Library...
Processing E:\源代码\execisecode\INPROC\SERVER.IDL
SERVER.IDL
Processing F:\Microsoft Visual Studio\VC98\INCLUDE\unknwn.idl
unknwn.idl
Processing F:\Microsoft Visual Studio\VC98\INCLUDE\wtypes.idl
wtypes.idl
Processing F:\Microsoft Visual Studio\VC98\INCLUDE\oaidl.idl
oaidl.idl
Processing F:\Microsoft Visual Studio\VC98\INCLUDE\objidl.idl
objidl.idl
E:\源代码\execisecode\INPROC\SERVER.IDL(21) : error MIDL2311 : statements outside library block are illegal in mktyplib compatability mode : [ Interface 'IX'  ]
E:\源代码\execisecode\INPROC\SERVER.IDL(21) : error MIDL2096 : duplicated attribute : [helpstring] [ Interface 'IX'  ]
E:\源代码\execisecode\INPROC\SERVER.IDL(21) : error MIDL2096 : duplicated attribute : [uuid] [ Interface 'IX'  ]
E:\源代码\execisecode\INPROC\SERVER.IDL(34) : error MIDL2311 : statements outside library block are illegal in mktyplib compatability mode : [ Interface 'IY'  ]
E:\源代码\execisecode\INPROC\SERVER.IDL(34) : error MIDL2096 : duplicated attribute : [helpstring] [ Interface 'IY'  ]
E:\源代码\execisecode\INPROC\SERVER.IDL(34) : error MIDL2096 : duplicated attribute : [uuid] [ Interface 'IY'  ]
E:\源代码\execisecode\INPROC\SERVER.IDL(42) : error MIDL2311 : statements outside library block are illegal in mktyplib compatability mode : [ ]
E:\源代码\execisecode\INPROC\SERVER.IDL(60) : error MIDL2311 : statements outside library block are illegal in mktyplib compatability mode : [ Interface 'IZ'  ]
E:\源代码\execisecode\INPROC\SERVER.IDL(60) : error MIDL2096 : duplicated attribute : [helpstring] [ Interface 'IZ'  ]
E:\源代码\execisecode\INPROC\SERVER.IDL(60) : error MIDL2096 : duplicated attribute : [uuid] [ Interface 'IZ'  ]
Error executing midl.exe.
我可都是按照书上的代码编译的阿。
server.idl内容:
import "unknwn.idl" ; // Interface IX
[
object,
uuid(32bb8323-b41b-11cf-a6bb-0080c7b2d682),
helpstring("IX Interface"),
pointer_default(unique)
]
interface IX : IUnknown
{
HRESULT FxStringIn([in, string] wchar_t* szIn) ;
HRESULT FxStringOut([out, string] wchar_t** szOut) ;
} ;// Interface IY
[
object,
uuid(32bb8324-b41b-11cf-a6bb-0080c7b2d682),
helpstring("IY Interface"),
pointer_default(unique)
]
interface IY : IUnknown
{
HRESULT FyCount([out] long* sizeArray) ; HRESULT FyArrayIn([in] long sizeIn, 
        [in, size_is(sizeIn)] long arrayIn[]) ; HRESULT FyArrayOut([out, in] long* psizeInOut, 
        [out, size_is(*psizeInOut)] long arrayOut[]) ;
} ;// Structure for interface IZ
typedef struct 
{
double x ;
double y ;
double z ;
} Point3d ;// Interface IZ
[
object,
uuid(32bb8325-b41b-11cf-a6bb-0080c7b2d682),
helpstring("IZ Interface"),
pointer_default(unique)
]
interface IZ : IUnknown
{
HRESULT FzStructIn([in] Point3d pt) ;
HRESULT FzStructOut([out] Point3d* pt) ;
} ;//
// Component descriptions
//
[
uuid(d3011ee0-b997-11cf-a6bb-0080c7b2d682),
version(1.0),
helpstring("Component1.0 Type Library")
]
library ServerLib
{
importlib("stdole32.tlb") ; // Component 1
[
uuid(0c092c29-882c-11cf-a6bb-0080c7b2d682),
helpstring("Component 1 Class")
]
coclass Component1
{
[default] interface IX ;
interface IY ;
interface IZ ;
}; // Component 2
[
uuid(0c092c2a-882c-11cf-a6bb-0080c7b2d682),
helpstring("Component 2 Class")
]
coclass Component2
{
[default] interface IY ;
interface IZ ;
}; // Component 3
[
uuid(0c092c2b-882c-11cf-a6bb-0080c7b2d682),
helpstring("Component 3 Class")
]
coclass Component3
{
[default] interface IZ ;
} ;
} ;

解决方案 »

  1.   

    没人解答啊?请问大家安装的机器上有没有mspdb60.dll这个文件了?如果有麻烦传一个给我:
    [email protected]
    谢谢!!
      

  2.   

    你用ATL向导创建一个Com对象,看看ATL生成的IDL文件的结构,再看看自己的,也许就找到毛病了!
      

  3.   

    你把
    import "unknwn.idl" ;
    改成
    import "oaidl.idl";
    import "ocidl.idl";
    试试
      

  4.   


    typedef struct 
    {
    double x ;
    double y ;
    double z ;
    } Point3d ;
    放到
    library ServerLib里面,不然在客户端不可用!