vector as out parameter

in Help Center
I'm using sequence as output parametr, but on client side after completion
procedure, that calling server's method, I'm receive error.
This error - error deleting vector.
Tell me please, what i do incorrectly?
server code
and client
procedure, that calling server's method, I'm receive error.
This error - error deleting vector.
Tell me please, what i do incorrectly?
-
//test.ice
class Driver
{
int idDriver;
string sDriverName;
int idDriverStatus;
int idDriverBase;
string sDescription;
};
sequence<Driver> TDriver;
interface IDriver
{
int GetDrivers(int idClient,out TDriver vDriver);
}
server code
-
class _Driver : public IDriver
{
public:
virtual int GetDrivers(int idClient,TDriver &,const Ice::Current &);
};
int _Driver::GetDrivers(int idClient,TDriver & vDriver, const Ice::Current &)
{
for(int i=0;i<10;i++)
{
Driver* dr=new Driver();
dr->idDriver=i;
dr->sDriverName="";
dr->idDriverStatus=i*i;
dr->sDescription="";
dr->idDriverBase=i*i+i
vDriver.push_back(dr);
}
return 1;
}
and client
-
............
TDriver vDriver;
pDriver->GetDrivers(ID,vDriver);
return;
0
Comments
I can't see anything wrong with your code and I tried doing something similar and it worked fine. Can you please give more details on which Ice version you are using and which operating system? What error are you getting? If that's a crash (segementation fault, abort), can you you send us the stack trace of the crash?
Benoit.
OS - Windows XP
I'm using VS 2003
error is appear when vector on client free automaticaly...
about stack tracer - hm.....
I'm receive this error:
Unhandled exception at 0x77f767cd in DriverClient.exe: User breakpoint.
How I can see stack tracer?
If you link with the Ice *d.lib libraries, you must compile your code with /MDd.
If you link with the Ice release (no d) lib, you must compile your code with /MD.
Also to get proper stack traces, you need to install the Ice PDB files (provided as a separate download).
Cheers,
Bernard
I'm link with the Ice *d.lib libraries, compile with /MDd.
Debug output:
'DriverClient.exe': Loaded 'C:\Dev\VC\Driver\DriverClient\Debug\DriverClient.exe', Symbols loaded. 'DriverClient.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\Dev\VC\Driver\DriverClient\Debug\ice14d.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\WINDOWS\system32\ws2_32.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\WINDOWS\system32\ws2help.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\Dev\VC\Driver\DriverClient\Debug\iceutil14d.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\Dev\VC\Driver\DriverClient\Debug\msvcp70d.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\Dev\VC\Driver\DriverClient\Debug\msvcr70d.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\WINDOWS\system32\mfc71d.dll', Symbols loaded. 'DriverClient.exe': Loaded 'C:\WINDOWS\system32\msvcr71d.dll', Symbols loaded. 'DriverClient.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\WINDOWS\system32\user32.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\WINDOWS\system32\comctl32.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\WINDOWS\system32\ole32.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\WINDOWS\system32\msvcp71d.dll', Symbols loaded. 'DriverClient.exe': Loaded 'C:\WINDOWS\system32\uxtheme.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\WINDOWS\system32\MSCTF.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\Usr\Panda Antivirus Platinum\Enganche.dll', No symbols loaded. First-chance exception at 0x77e73887 in DriverClient.exe: Microsoft C++ exception: CL_EXCEPCION_FINAL_FUNCION @ 0x0012e5ec. First-chance exception at 0x77e73887 in DriverClient.exe: Microsoft C++ exception: CL_EXCEPCION_FINAL_FUNCION @ 0x0012e727. 'DriverClient.exe': Loaded 'C:\WINDOWS\system32\mswsock.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\WINDOWS\system32\dnsapi.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\WINDOWS\system32\winrnr.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\WINDOWS\system32\wldap32.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\WINDOWS\system32\rasadhlp.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\WINDOWS\system32\wshtcpip.dll', No symbols loaded. 'DriverClient.exe': Loaded 'C:\Usr\Panda Antivirus Platinum\Firewall\SSSensor.dll', No symbols loaded. First-chance exception at 0x77e73887 in DriverClient.exe: Microsoft C++ exception: Ice::TimeoutException @ 0x0140e320. HEAP[DriverClient.exe]: Invalid Address specified to RtlValidateHeap( 00680000, 014D22B0 ) Unhandled exception at 0x77f767cd in DriverClient.exe: User breakpoint.
When you call the distributed Ice operation, you should catch exceptions to avoid such crash.
Then you need to figure out why you get a timeout. Maybe the operation on the the server-side takes too long?
Cheers,
Bernard
When I diminish data in vDriver, all work right.......
Why?
server initialization
int argc = 0; Ice::PropertiesPtr properties = Ice::createProperties(); properties->setProperty("Driver.Endpoints", "tcp -p 9096"); properties->setProperty("Ice.Trace.Network", "1"); properties->setProperty("Ice.Warn.Connections", "1"); properties->setProperty("Ice.Override.ConnectTimeout","100000"); properties->setProperty("Ice.ThreadPool.Server.Size","10"); communicator = Ice::initializeWithProperties(argc, 0, properties); adapter = communicator->createObjectAdapter("Driver"); Ice::ObjectPtr servant = new _Driver; adapter->add(servant, Ice::stringToIdentity("driver")); adapter->activate(); communicator->waitForShutdown();
and how to I can delete Driver objects (creating on server) in vDriver on Client?
Sorry, from the information you provide it's not possible to say what's going wrong. We would need a small, self-contained code example that demonstrates the problem.
For a code example that sends and receives sequences, have a look at demo/Ice/throughput.
You add a destroy() method to your Ice object, which the client can call. The implementation on the server then cleans up any resources associated with the Ice object, and removes the servant from the object adapter.
dr->sDriverName="This is Petrov Ivanovich"; //error on client
anddr->sDriverName="1"; //ok
Thanks for the example.
I tried it on Windows XP with VS.NET 2003 and encountered the memory mismatch error. Then I realized that I was linking against the Ice 1.4.0 binary distribution for VS.NET 2002. After I installed the proper Ice binaries, I no longer received the error.
Is it possible that you are using the Ice 1.4.0 binary distribution for VS.NET 2002?
Take care,
- Mark
I uninstall Ice and install it anew. All work fine