Hello,
I'm trying to do my first steps with Caches CPP Interface at the moment.
I�ve created a very simple class:

Class demo.Pet Extends %Persistent [ ClassType = persistent,
ProcedureBlock ]
{
Property Name As %String;

}

After that,I�ve generated  the C++ header and implementation files and
filled the Database with some

testdata.

So far so good.

Here is my C++ code:

#include <iostream>
#include "demo_Pet.h"

typedef d_ref<demo_Pet> d_Pet;

int main()
{
 Db_err conn_err;
 d_connection conn;
 d_Pet tier;

 conn= tcp_conn::connect("localhost[1972]:PET","_system","sys",&conn_err);

 if(conn_err)
 {
  std::cerr<<"Fehler :"<<conn_err<<'\n';
 }
 try
 {
  Database db(conn);
  std::wstring id;
  std::wcin>>id;

  tier = demo_Pet::openid(&db,id.c_str());
  std::cout<< tier->getName()<<'\n';

  return 0;
 }
 catch(Db_err &err)
 {
  std::cerr<<err<<'\n';
   return -1;
 }
}



The little program that I have written compiles without any errors or
warnings.

At runtime the name is shown on then screen,but now -when the objects should
be closed automatically-there

 comes an error message:

Error: code = -8, msg = forcefully closed some objects


A little bit later windows report an Access Violation in Cppbind.dll .

I�ve tried several variations,such as opening more objects and creating new
objects.For each object that was opened

or was newly created comes one AccessViolation.

With the debugger I�ve set the reference counter of the d_ref of the object
to 2,to avoid the "Smartpointer" to destroy the object after leaving the try
block.That works,the AccessViolation wasn�t raised.

So it seems that the d_ref Smartpointer want to delete the object twice or
wants to delete memory behind an uninitialized pointer.

My question is: whats wrong with my code??

I think it�s mostly the same as the samples in the documentation!?

I hope someone could help me because the Cache community in Germany is very
poor!

Sorry,for my bad english ;)    I havn�t written something english for more
then 10 years...

Greetings

M.Wagemeyer




Reply via email to