我用vc写了一个dll,名字叫作:SpeedServer.dll
里面有一个接口ILogin
ILogin中有个方法:isMember
然后我准备在vc写的客户端中调用,我准备使用聪明指针
可是编译的时候没有问题,一运行竟然出现一个叫做asserts的错误
请问到具体的使用聪明指针的步骤是什么?
是不是先在StdAfx.h里面加上
#import "E:\Program Files\Microsoft Visual Studio\MyProjects\SpeedServer\Debug\SpeedServer.dll" 
#include <atlbase.h>
然后再使用的地方:
CComPtr<ILogin> ll;
log.CoCreateInstance(OLESTR("SpeedServer.Login"));
log->isMember
我真的不知道到底应该怎么办了!!!!!谁要是能解答一定给满分!!!!!100分

解决方案 »

  1.   

    #import "E:\\Program Files\\Microsoft Visual Studio\\MyProjects\\SpeedServer\\Debug\\SpeedServer.tlb" raw_interfaces_only  raw_native_types no_namespace
    ...
    ILoginPtr pLog;
    pLog.CreateInstance(__uuidof(Login));
    pLog->isMember(..);
    ...
      

  2.   

    #import "E:\Program Files\Microsoft Visual Studio\MyProjects\SpeedServer\Debug\SpeedServer.tlb" rename_namespace("SS")调用:
    SS::ILoginPtr pLogin(L"SpeedServer.Login");
    pLogin->isMember(..);
      

  3.   

    你的ASSERTS错误出现在哪个文件,在哪一行?
      

  4.   

    试试:
    #import "E:\Program Files\Microsoft Visual Studio\MyProjects\SpeedServer\Debug\SpeedServer.dll" 
    using namespace "SpeedServerLIB"ILoginPtr pLog;
    pLog.CreateInstance(__uuidof(Login));
    pLog->isMember(..);
      

  5.   

    你把所有的import都放到所有头文件包含下面试试,应该没问题的。
      

  6.   

    我通过使用下面的代码,虽然实现了,但是还是根本就不明白到底是怎么一回事,请先看看这段执行成功的代码:
    ////////////////////////////
    CoInitialize(NULL);
    ILoginPtr cl(__uuidof(Login));
    cl->isMember(...);
    cl.Release();
    CoUninitialize();
    ////////////////////////////
    现在的问题有这么几个:
    1,ILoginPtr这个聪明指针是在那里声明的?怎么可以直接使用?
    2, cl.Release()这一句为什么不能使用cl->Release()(总是出错)
    3, 如果我不用ILoginPtr,而是换用CComPtr,应该怎么做?
      

  7.   

    cl.Release();
    这句有问题,不用的