3 messages in com.mysql.lists.win32RE: Embedded library in a .Net (C#) a...
FromSent OnAttachments
Adam Clauss21 Apr 2004 12:12 
Reggie Burnett21 Apr 2004 22:27 
Adam Clauss28 Apr 2004 12:25 
Subject:RE: Embedded library in a .Net (C#) application?
From:Adam Clauss (caba@houston.rr.com)
Date:04/28/2004 12:25:15 PM
List:com.mysql.lists.win32

Hmm... OK, I looked up the Pinvoke method of doing this. I'm *pretty* sure I got the C# part of it right, but I'm getting a NullPointerException being thrown in the call to mysql_server_init.

To track it down, I built the debug version of libmysqld.dll and traced in.

The problem seems to occur in my_thread_global_init (my_thr_init.c line 60(called from my_init() which is called from mysql_server_init). The first thing it does is call pthread_key_create. However, while returning true, this seems to leave THR_KEY_mysys as null. The exception then occurs a little later when a member of THR_KEY_mysys is accessed (line 169).

Any ideas as to why it would not be initialized? Is there some issue with using the Pinvoke method to call native DLLs and then creating threads?

I tried tracing into the pthread_key_create, but when I traced in, all I got was: pthread_dummy (my_pthread.c line 542). Which takes a default value of 0 as a parameter and just returns it.

Adam, you can use the embedded library with C#. You would need to write some PInvoke statements to provide the method signatures.

I'm writing an application right now in C#. As of now, I connect to an external MySQL server (external being either locally on the same computer or actually on another machine). I would like to also have the option of using the embedded library so that there does not have to be an external data source. Has anyone gotten this to work?