Archived

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

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;
}
}
}

Comments

  • benoit
    benoit Rennes, France
    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.