views:

30

answers:

0

Hi,

I have written a stand-alone Windows Forms application in Visual Studio 2005 using C#, CastleProject ActiveRecord and SQLite as database (using the SQLite connector).

The published application (the binaries from the bin directory) works perfectly on windows vista and windows 7 computers, however when copied to a Windows XP computer the application gives an error somewhere when running:

"Could not perform FindByPrimaryKey for [tablename] Id: 422"

The strangest thing is that the ID 422 does exist, so are the tables and the database (and no inconsistencies can be found).

Some other details:

  • The windows xp sp3 system has all the libraries / frameworks installed
  • The application does start normally on the xp machine
  • If the application is being run in visual studio on the XP machine, the program runs just fine without any problems. But running it outside of visual studio (same binary), gives the error again.
  • No problems on Vista & W7
  • I am using the latest SQLite connector (http://sourceforge.net/projects/sqlite-dotnet2/)
  • When I copy the SQLite database file from the XP machine to Vista or W7, the application on those systems reads it without problem
  • The error is not showing up at all the other database actions that took place before the errornous call
  • Changing FindByPrimaryKey to FindAll will cause a similar error

I have no clue what could be causing it... Anyone an idea?

Update:

Ok, found the problem (still very weird, but it might be because I'm using it wrong):

In the app.config, at the line where the database location is defined:

<add key="hibernate.connection.connection_string" value="Data Source=database.db;Version=3"/>

On XP the path (in Data Source) is relative to any other file action path, while on Windows Vista or Windows 7 it is always relative to the path of the main executable.

So.. different question, but same problem:

How do I define the database path so that it always points to the same location? (for example: the same directory as the executable, and ofcourse without absolute paths)

Update 2

Ok got it, from the official castleproject documentation:

http://www.castleproject.org/activerecord/documentation/v1rc1/usersguide/configref.html#configuring