Archived
This forum has been archived. Please start a new discussion on GitHub.
Unknow exception in "Printer" sample code
I just copy the code of "Printer" sample to my application ,but it report a exception in file dbgheap.c,the error locate at "_CRTIMP void * __cdecl malloc " ,nSize=3765269347 in this time . The demo of printer is ok.
ice file : use printer.ice
my code complie ok.
Client code:
int status =0;
Ice::CommunicatorPtr ic;
try {
ic = Ice::initialize(argc, argv);
Ice::ObjectPrx base = ic->stringToProxy("CstaLink:default -p 10000");
PrinterPrx printer = PrinterPrx::checkedCast(base);
if (!printer)
throw "Invalid proxy";
try{
printer->printString("Hello World!");
}catch(CException *ex)
{
}
} catch (const Ice::Exception & ex) {
cerr << ex << endl;
status = 1;
} catch (const char * msg) {
cerr << msg << endl;
status = 1;
}
if (ic) {
try {
ic->destroy();
} catch (const Ice::Exception & ex) {
cerr << ex << endl;
status = 1;
}
}
Server Code:
Ice::CommunicatorPtr _communicator;
Ice::ObjectAdapterPtr _adapter;
try{
_communicator=Ice::initialize(argc,argv);
_adapter=_communicator->createObjectAdapterWithEndpoints("CstaLinkAdapter","default -p 10000");
_adapter->add(new PrinterI,_communicator->stringToIdentity("CstaLink"));
_adapter->activate();
_communicator->waitForShutdown();
}catch (const Ice::Exception& e){
std::cout<<e<<std::endl;
return 1;
}catch (const char* msg)
{
return 1;
}
try{
_adapter->deactivate();
_adapter->waitForDeactivate();
_communicator->destroy();
}catch(const Ice::Exception& e){
//...
cout<<e<<endl;
}
ice file : use printer.ice
my code complie ok.
Client code:
int status =0;
Ice::CommunicatorPtr ic;
try {
ic = Ice::initialize(argc, argv);
Ice::ObjectPrx base = ic->stringToProxy("CstaLink:default -p 10000");
PrinterPrx printer = PrinterPrx::checkedCast(base);
if (!printer)
throw "Invalid proxy";
try{
printer->printString("Hello World!");
}catch(CException *ex)
{
}
} catch (const Ice::Exception & ex) {
cerr << ex << endl;
status = 1;
} catch (const char * msg) {
cerr << msg << endl;
status = 1;
}
if (ic) {
try {
ic->destroy();
} catch (const Ice::Exception & ex) {
cerr << ex << endl;
status = 1;
}
}
Server Code:
Ice::CommunicatorPtr _communicator;
Ice::ObjectAdapterPtr _adapter;
try{
_communicator=Ice::initialize(argc,argv);
_adapter=_communicator->createObjectAdapterWithEndpoints("CstaLinkAdapter","default -p 10000");
_adapter->add(new PrinterI,_communicator->stringToIdentity("CstaLink"));
_adapter->activate();
_communicator->waitForShutdown();
}catch (const Ice::Exception& e){
std::cout<<e<<std::endl;
return 1;
}catch (const char* msg)
{
return 1;
}
try{
_adapter->deactivate();
_adapter->waitForDeactivate();
_communicator->destroy();
}catch(const Ice::Exception& e){
//...
cout<<e<<endl;
}
0
Comments
-
replay
I have checked the environment of client project.It include right lib.
But i copy my code of client to "printerC" project of demo, it work ok.
The framework code of My Client project is create by VC7.It's a win32 console app support ATL and MFC.I just set it "not use precompile file".
I just want to know what is difference in my client project and PrinterC demo project .
thks.0 -
I still believe it is a library mix-up. The exception you get is typical for the situation when a release library allocates memory that is freed by a debug library, or vice versa.
If you like, we can investigate your project's settings as consulting or support services. In this case, please contact us at info@zeroc.com.0 -
i have send u mail!
i hav send my source code to your in mail.
thks0 -
It is almost certain that you are linking with IceD.lib and compiling with release mode, or compiling debug mode and linking with the non-D lib's. You should check what Ice library you are linking with and runtime library you are compiling against.
To be concrete: If you compile with the debug runtime library you need to link against the *D.libs (ie: IceD.lib IceUtilD.lib). If you compile with the non-debug runtime library then you need to link against the non-D lib's (ie: Ice.lib IceUtil.lib, etc.)0 -
Can you send the code modified to me ?
Hi,
I just want the code you modified .
Do you run right on your computer after modified my code ?0