Archived

This forum has been archived. Please start a new discussion on GitHub.

Difference of ice code in dll or exe?

The same (client side) ice code ,in dll (call by main exe as export function ) or in exe (inline).
The code in main exe can run fine.

But the same code in dll ,then be called by main exe ,the vc2003 debuger throw the error?

My question is when I put the (client side) ice code in dll ,and call by the main exe program, what should I do?

Comments

  • The DLL part:

    void __declspec( dllexport ) getowners(::worm::OwnerSeq &os)
    {
    ........................
    communicator = Ice::initialize(argc, 0);

    Ice::ObjectPrx obj = communicator->stringToProxy("localhost:tcp -p 888888:udp -p 888888

    mproxy=0;

    mproxy = localhost::UserHostPrx::uncheckedCast(obj);

    mproxy->GetServerManager(lockkey,sm);
    ...
    sm=::worm::ServerManagerPrx::uncheckedCast(sm);




    sm->GetAllOwner(os);


    ........................
    }

    The Main part:


    void mmdlg::OnBnClickedButton1()
    {
    ::worm::OwnerSeq os;
    getowners(os);//this function in dll part;
    ....
    ::worm::OwnerPrx own1;
    try
    {

    own1=::worm::OwnerPrx::checkedCast(os[0]);
    own1->ice_ping();//error !!!!!!!!!!!!why??
    }
    catch(const IceUtil::Exception& ex)
    {
    std::ostringstream ostr;
    ostr << ex;
    std::string s = ostr.str();
    AfxMessageBox(CString(s.c_str()), MB_OK|MB_ICONEXCLAMATION);
    }


    ::worm::StringSeq desc;

    desc.push_back("HostName");

    ::worm::StringSeq info;

    try
    {
    own1->PullString(desc,info);//ice: PullString (stringseq desc,stringseq info);
    //stringseq==> sequence<string> stringseq;
    }
    catch(...)
    {

    }
    AfxMessageBox(_T(info[0].c_str()));

    ....

    }

    If I paste the code in dll to main exe (in function OnBnClickedButton1),the code run fine. why?
  • mes
    mes California
    What error do you get?

    Are you sure that you are compiling the main program and the DLL with the same compiler options?

    - Mark
  • the same code (the client side ) could not get the same result in dll and in main exe.
    And in the dll ,the vc2003 debuger throw the error ,that the error could not be catch by ice.
    Could you write the example that the client program call the function (all the ice code ).
  • Sorry ,
    I have find the cause.It isnot ice 's error.
    My dll (debug) is not link iced.lib ,:D .

    I'm sorry for wasted your time.