Debugging mysql_server_init() crash
Posted by: Brett Powell
Date: October 19, 2011 06:27PM

The mysql_server_init() function seems to return 0 if success, 1 if error. Unfortunately, in my code when it returns 1, and I use Marshal.GetLastWin32Error() the error code is 0. I am assuming that it is not picking up on the error being generated by mysql_server_init(), but I am at a loss as to how to find out where the problem is now.

Here is the relevant code block...

[DllImportAttribute("libmysqld.dll", SetLastError = true)]
static extern int mysql_server_init(int argc, string[] argv, string[] groups);

static string[] server_options = new string[2];
static string[] server_groups = new string[3];

public static bool Start()
{
server_options[0] = "mysql_test"; // not used?
server_options[1] = "--defaults-file=./my.ini";

server_groups[0] = "client";
server_groups[1] = "server";
server_groups[2] = "\0";

if (mysql_server_init(2, server_options, server_groups) != 0)
{
int lastError = Marshal.GetLastWin32Error();
Console.WriteLine("MySQL Library Init Failed with error code: " + lastError);
return false;
}

Console.WriteLine("MySQL Library Started Successfully!");
return true;
}

Options: ReplyQuote


Subject
Written By
Posted
Debugging mysql_server_init() crash
October 19, 2011 06:27PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.