Embedded Server Setup

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
Wizard_TPG
Posts: 12
Joined: Mon 26 Sep 2005 04:33

Embedded Server Setup

Post by Wizard_TPG » Wed 22 Mar 2006 22:59

I am trying to setup my application with an embedded mysql server in it.

I followed the MySQLDirect .NET instructions on how to obtain and build a libmysqld.dll library (Using version 4.1.18 of mysql source)

Unfortunately, when I attempt to add this library to my project's references I get the following message

A reference to 'C:\mypath\libmysqld.dll' could not be added. This is not a valid assembly or COM object. Only assemblies with extension 'dll' and COM components can be referenced. Please make sure that the file is accessible, and that it is a valid assembly or COM component.


Can anyone shed any light on what I might have done wrong?

Wizard_TPG
Posts: 12
Joined: Mon 26 Sep 2005 04:33

Post by Wizard_TPG » Wed 22 Mar 2006 23:07

I just realised that the new version of MySQLDirect.Net that I just installed has a different set of instructions for setting up embedded serevr applications.

I will try those.

Serious

Post by Serious » Thu 23 Mar 2006 09:10

You shouldn't add "libmysqld.dll" reference to your project.
Just place it in the folder accessible to your application (refer to LoadLibrary function documentation).

Wizard_TPG
Posts: 12
Joined: Mon 26 Sep 2005 04:33

Post by Wizard_TPG » Tue 28 Mar 2006 05:21

I am still having troubles getting an embedded server to work.

I have done the following steps:
- Downloaded mysql installer 4.1.18
- Installed and configured mysql. Tested that it works in client console
- Shut down mysql service
- Copied libmysqld.dll into C:\Windows

I then have been trying various usages of this code...

Code: Select all


			MySqlConnectionStringBuilder myCSB = new MySqlConnectionStringBuilder(); 
			myCSB.ServerParameters = "--basedir=C:\Program Files\MySQL\MySQL Server 4.1;--datadir=C:\Program Files\MySQL\MySQL Server 4.1\data;";
			//myCSB.Host = "localhost";
			myCSB.Embedded = true;
			myCSB.UserId = "root"; 
			myCSB.Password = "mypass";
			//myCSB.Database = dbaseName; 
			myConn = new MySqlConnection(myCSB.ConnectionString);
			MySqlDataReader myReader = null;
			try 
			{ 
				string myQuery = "show variables"; 
				MySqlCommand myCommand = new MySqlCommand(myQuery); 
				myCommand.Connection = myConn; 

				myConn.Open(); 

				myReader = myCommand.ExecuteReader(); 
				while(myReader.Read()) 
				{ 
					string myStr = myReader.GetString(0); 
				} 
			} 
			catch(Exception e)
			{
				//write error to log file
				new error().throwNote("CACHE: Error accessing Embedded MYSQL server - "+e.ToString());
			}			
			finally 
			{ 
				myReader.Close(); 
				myConn.Close(); 
			} 
Everything I try seems to cause an exception at myConn.Open(); and throws this error...
2:13 PM - NOTE: CACHE: Error accessing Embedded MYSQL server - System.ApplicationException: Error in the application.
at CoreLab.MySql.i..ctor(String[] A_0)
at CoreLab.MySql.MySqlInternalConnection.Connect(String userId, String password, String host, String database, Int32 port, Int32 connectionTimeout, MySqlProtocol protocol, Boolean compress)
at CoreLab.MySql.MySqlInternalConnection..ctor(af connectionOptions)
at CoreLab.MySql.a5.a(DbConnectionOptions A_0, Object A_1, DbConnectionBase A_2)
at CoreLab.Common.DbConnectionFactory.a(DbConnectionPool A_0, DbConnectionOptions A_1)
at CoreLab.Common.DbConnectionPoolGroup.c(DbConnectionPool A_0)
at CoreLab.Common.DbConnectionPool.a()
at CoreLab.Common.DbConnectionPool.GetObject()
at CoreLab.Common.DbConnectionFactory.a(DbConnectionBase A_0)
at CoreLab.Common.DbConnectionClosed.Open(DbConnectionBase outerConnection)
at CoreLab.Common.DbConnectionBase.Open()
at CoreLab.MySql.MySqlConnection.Open()
at DLA.core.cache.MysqlCache.test() in c:\documents and settings\dneilsen\my documents\visual studio projects\timesheet\core\cache\mysqlcache.cs:line 150
I am positive I am missing some step but just not sure what.
Any help would be appreciated.

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Tue 28 Mar 2006 14:11

The problem you experience occurs when basedir parameter in ServerParameters attribute is incorrect. Please check it.

Wizard_TPG
Posts: 12
Joined: Mon 26 Sep 2005 04:33

Post by Wizard_TPG » Tue 28 Mar 2006 23:29

Those paths definetly exist and are setup correctly.

The basedir path has the share directory (and its contents) under it
The datadir path has the contents of the default mysql install data dir in it.

The mysql manual describes the use of several functions
mysql_server_init();
mysql_thread_init();
mysql_thread_end();
mysql_server_end();

Do I have to do something with these? I am not sure how to access them as I am unfamiliar with linking unmanaged librarys.

Wizard_TPG
Posts: 12
Joined: Mon 26 Sep 2005 04:33

Post by Wizard_TPG » Wed 29 Mar 2006 02:07

Just for the record. If I connect to the mysql server normally (when the service is running) it runs fine.

Wizard_TPG
Posts: 12
Joined: Mon 26 Sep 2005 04:33

Post by Wizard_TPG » Wed 29 Mar 2006 03:33

I have tried everything I can think of.

Does anyone have a complete, working example of how this is done?

Nothing I have tried is working.
I think I may have to look at another method of client storage. :(

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Wed 29 Mar 2006 11:25

An example has been sent to [email protected]

Post Reply