MySqlClient ReplicationManager exception

3.1k views Asked by At

I set up a test project to connect to a MySQL database (in Visual Studio 2013 Express, using C#). [This is my first time working with SQL.]

I got it working; I can successfully connect to my local database. However, when I copied my connection code to another project, I get the error

"The type initializer for 'MySql.Data.MySqlClient.Replication.ReplicationManager' threw an exception."

My searches about this problem have turned up the solution of enabling "SQL Server Debugging", but this option doesn't seem to exist in the Express versions of Visual Studio.

How can I fix this error in Visual Studio Express? (The project I copied the code to was made in VS2012, if that matters.)

My code (works in my test project, but not in my other project):

        MySqlConnection cn = new MySqlConnection();
        cn.ConnectionString = "server=127.0.0.1; userid=newUser1; password=mysql; " +
            "database=pr2_db";
        cn.Open();

EDIT: The code works if I start the program without debugging.

0

There are 0 answers