Results 1 to 2 of 2

Thread: ICE Server support MFC project based dialog?

  1. #1
    mrliuhua is offline Registered User
    Name: liu hua
    Organization: chinastock
    Project: fund evaluation
    Join Date
    Oct 2009
    Posts
    4

    ICE Server support MFC project based dialog?

    can ice server program support mfc project based dialog ? i have developed a mfc project based dialog with ice, but ice has memory allocation error?
    why?
    code is below:
    void CQuoteSvrDlg::OnBnClickedStart()
    {
    // TODO: Add your control notification handler code here
    int status = 0;
    Ice::CommunicatorPtr ic;
    try {
    int argc;
    //char* argv[] = {"0"};
    ic = Ice::initialize();
    Ice::ObjectAdapterPtr adapter
    = ic->createObjectAdapterWithEndpoints(
    "HelloAdapter", "default -h 127.0.0.1 -p 10000");
    Ice::ObjectPtr object = new HelloI;
    adapter->add(object,
    ic->stringToIdentity("Hello"));
    adapter->activate();
    ic->waitForShutdown();
    } catch (const Ice::Exception & e) {
    //cerr << e << endl;
    status = 1;
    } catch (const char * msg) {
    //cerr << msg << endl;
    status = 1;
    }
    if (ic) {
    try {
    ic->destroy();
    } catch (const Ice::Exception & e) {
    //cerr << e << endl;
    status = 1;
    }
    }
    }
    Last edited by mrliuhua; 10-25-2009 at 10:34 PM. Reason: modify

  2. #2
    benoit's Avatar
    benoit is offline ZeroC Staff
    Name: Benoit Foucher
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Rennes, France
    Posts
    2,196
    Hi,

    Yes, an MFC application can also be an Ice server. For an example, see the demo/Ice/MFC client and server from your Ice distribution.

    A memory allocation error is often caused by a library mismatch in your project: see this FAQ and make sure you correctly link with iceutild.lib and iced.lib when building your application in debug mode (and iceutil.lib and ice.lib for the release mode).

    Also, calling waitForShutdown() from OnBnClickedStart will cause the GUI thread to hang and it won't be able to dispatch further events. I suspect you shouldn't call it here but instead call it when your application terminates.

    Cheers,
    Benoit.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Support for UDP-based protocols?
    By boxerab in forum Help Center
    Replies: 3
    Last Post: 09-22-2009, 11:46 AM
  2. Is there any open source project based on ICE?
    By ffmpeg4nmm in forum Comments
    Replies: 3
    Last Post: 05-28-2006, 10:23 PM
  3. Link error when adding MFC header in dll project
    By emoly in forum Help Center
    Replies: 7
    Last Post: 09-12-2005, 07:49 AM
  4. in MFC dialog project Detected memory leaks!
    By dzw in forum Help Center
    Replies: 2
    Last Post: 07-28-2004, 11:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •