VB.NET VS2010 error Object reference not set to an instance of an object.

Feb 21, 2013 at 7:20 AM
Hi I'm new here.I just need a solution to backup mysql data. I add up the reference in my vb.net project.
Mysqlbackup is 1.5.7.0 and Mysql.Data is 6.6.4.0 . I did just a simple backup by opening new form and add a button when user click on that button here are the code

Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim con As String = "server=localhost;user=root;pwd=myrootpassword;database=mymember;"
    Dim file As String = "C:\backup.sql"
    Dim mb As New MySqlBackup(con)
    mb.ExportInfo.FileName = file
    mb.Export()
    MsgBox("ได้ทำการ backup แล้ว")
End Sub
** mymber is the database that I wanted to backup

when user click I get an error at mb.export
NullReferenceException was unhandled
Object reference not set to an instance of an object.

thanks
Feb 22, 2013 at 8:19 PM
Ok I found the solution to my problem in case others face the same problem. It's easy!!!
The backup file can't be save on the C: drive .What I did was change
Dim File as String = "E:\backup.sql" and my problem is gone.
Bye.
Coordinator
Feb 26, 2013 at 12:37 AM
I see new bug here.
Thanks for the feedback.
Mar 26, 2013 at 1:20 PM
Edited Mar 26, 2013 at 1:22 PM
Hi,
I have the same problem here, but in C#.
ravitc's solution didn't work for me. Any ideas?
string db_connect = "SERVER=svaddress;" + "DATABASE=databasename_db;" + "UID=user;" + "PASSWORD=password;";
MySqlBackup mb = new MySqlBackup(db_connect);
mb.ExportInfo.FileName = @"E:\\backup.sql";
mb.Export();
Error: "Object reference not set to an instance of an object. "

StackTrace = " at MySql.Data.MySqlClient.MySqlBackup.ExportExecute()\r\n at MySql.Data.MySqlClient.MySqlBackup.Export()\r\n at advnotif.login_form.dbbackup() in c:\Users\projectaddress "
Mar 26, 2013 at 4:43 PM
Edited Mar 26, 2013 at 4:45 PM
Hi,
I've notice one more thing is that this dll call up mysqldump
(C:\Program Files\MySQL\MySQL Server 5.5\bin) in one of my computer I
can called this program on any subdirectory but in other machine that I face
the same problem , I copied the program on to the directory of
the form that call up the backup process. I also copied this file to the bin
directory of the project also . Try copy mysqldump to the directory that
you called up the program...hope this help. Please note if this solve your
problem don't forget to transfer this program when you build up setup
program.
Mar 27, 2013 at 1:29 AM
Try to copy mysqldump program into your form (the form that run the backup process)
mysqldump is under C:\Program Files\MySQL\MySQL Server 5.5\bin folder.
Mar 27, 2013 at 11:53 AM
Thank you for reply.
I installed an older version (1.4....) of dll using "Package Manager Console" following the steps mentioned here: TUTORIAL Package Manager Console, with the parameters mentioned in NuGet Gallery click here .

Here is the line:
PM> Install-Package MySqlBackup.NET 
Older versions than 1.4., work only on 32 bits.

This solution is working on both 32 and 64.

Good luck.
Coordinator
Dec 24, 2013 at 2:07 PM
Hi, new version of this project is released.
You can try again with new version :)