[odb-users] Problem - Using ODB inside a DLL

Boris Kolpackov boris at codesynthesis.com
Sun Dec 11 08:22:12 EST 2011


Hi Cuong,

Cuong Minh Tran <vaioinman at googlemail.com> writes:

> I am trying to use the set ODB - MYSQL/SQLite version 1.6 in my COM DLL,
> developed in MSVC 2010. I had no issues with compiling libodb, 
> libodb-mysql/sqlite on the same machine with my COM. My COM code also
> compiles without a problem. However, I want to trigger the COM in my
> application, the execution always fails at the (*) line:
> 
>          ...
>          // create database pointer
>     std::auto_ptr<odb::database> db ( create_database ( ) );
> (*) odb::transaction t (db->begin ());
>     //persist an simple object

It is hard to say what's going on without knowing exactly how you
created your "COM DLL" and without seeing the create_database()
database implementation. One fairly common cause would be if ODB
is unable to connect to the database (which in this case will
happen during the db->begin () call) though you said that
everything works fine in plain Win32 setup so it is probably not
it.

In any case, I went ahead and created a test "COM DLL" project as
described on this page:

http://msdn.microsoft.com/en-us/library/dssw0ch4(v=VS.90).aspx

I then added code similar to the above to the property's get_XXX()
function. However, everything is working fine for me. Could you try
this project and see if it works for you?

http://www.codesynthesis.com/~boris/tmp/odb/com_dll.zip

You will need to make some modifications in Object1.cpp to use
your MySQL connection parameters before you can run the test.

If it works for you as well, then you can try to modify it to
resemble your code until it fails. Then I would be able to take
a look.

Boris



More information about the odb-users mailing list