Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run in windows is ok, but centOS show error:Could not load file or assembly 'MySqlBackupNet.MySqlConnector, Version=2.3.6.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified. #83

Closed
CatcherX opened this issue Jan 23, 2022 · 4 comments

Comments

@CatcherX
Copy link

CatcherX commented Jan 23, 2022

Could not load file or assembly 'MySqlBackupNet.MySqlConnector, Version=2.3.6.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

my code is :

backupPath += "\" + DateTime.Now.ToString("yyyy-MM-dd_HH_mm_ss.sql");
using (MySqlConnection conn = new MySqlConnection(GlobalContext.SystemConfig.DBConnectionString))
{
using (MySqlCommand cmd = new MySqlCommand())
{
using (MySqlBackup mb = new MySqlBackup(cmd))
{
cmd.Connection = conn;
conn.Open();
mb.ExportToFile(backupPath);
conn.Close();
}
}
}

@adriancs2
Copy link
Member

MySqlBackupNet.MySqlConnector requires MySqlConnector.NET to run. You may download the .NET Core build of MySqlConnector.NET at: https://www.nuget.org/packages/MySqlConnector/

@adriancs2
Copy link
Member

adriancs2 commented Jan 26, 2022

The idea is to build the project in .NET Core.

We can test this out with a simple Console App.

07

Starting by creating a .net core linux project:

01

Check the project properties, ensure the project is built with .NET Core framework:

02

Install Nuget Package of MySqlBackup.NET (with MySqlConnector):

03

Next, is to publish the project for .NET Core (Linux):

08

04

In above example, the Linux compiled binaries are located at:

\bin\Release\netcoreapp3.1\publish\linux-x64

Copy the DLL in above folder and paste it to your CentOS

At the CentOS, make sure that you have installed Dotnet runtime by following command:

sudo dnf install dotnet-sdk-<version>

For example:

sudo dnf install dotnet-sdk-3.1
sudo dnf install dotnet-sdk-5.0

Assume that you have copied your .NET Core DLL files at the following folder:

/home/<username>/testapp

Then you can test out your app with following command:

cd /home/admin/testapp
dotnet ConsoleApp.dll

Here is the sample source code for your referrence:

ConsoleApp2.zip

@adriancs2
Copy link
Member

adriancs2 commented Jan 26, 2022

You can also compile the binaries into single "self-contained" binary. With this method, the .NET Core App can be run directly on CentOS (Linux) without installing any dotnet runtime.

Here is the screenshot for publishing the "self-contained" binary:

05

Here is the example of how it looks like after publishing, there is only 1 single file:

06

Copy the compiled binary to CentOS

At the terminal, browse to the folder that contains the self-contained binary, for example:

cd /home/admin/testapp

Next, is to allow execution permission to the file:

sudo chmod 777 ConsoleApp2

Execute the app:

./ConsoleApp2

@CatcherX
Copy link
Author

MySqlBackupNet.MySqlConnector requires MySqlConnector.NET to run. You may download the .NET Core build of MySqlConnector.NET at: https://www.nuget.org/packages/MySqlConnector/

It's working fine now, thank you very much for your patient guidance @adriancs2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants