有没有办法解决/更新旧的System.Runtime.Loader?

huangapple go评论88阅读模式
英文:

Is there a way to resolve/update an older System.Runtime.Loader?

问题

我在将我的Xamarin应用连接到服务器时遇到了困难。

当我尝试运行这段代码时:

try
{
    // 连接到MySQL服务器
    MySqlConnection connection = new MySqlConnection(connectionString);

    // 创建一个打开的连接(这会登录到服务器)
    connection.Open();

我在connection.Open();处遇到了错误,并抛出以下异常:

MySql.Data.MySqlClient.MySqlPoolManager' 抛出了一个异常。
$exception {System.TypeInitializationException: 'MySql.Data.MySqlClient.MySqlPoolManager' 的类型初始化程序引发了一个异常。---> System.IO.FileNotFoundException: 无法加载文件或程序集 'System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 或其依赖项之一,

看起来我缺少一个名为System.Runtime.Loader的文件,版本为4.0。在检查了资源后,我发现我有这个文件,但它的版本是较旧的1.0.24212.1。我应该采取哪些步骤来尝试解决这个问题?

英文:

I'm facing difficulties in getting my Xamarin app to connect to my server.

When I try to run this code:

try
        {
            // connect to the mySQL server
            MySqlConnection connection = new MySqlConnection(connectionString);

            // create an open connection (this logs into the server)
            connection.Open();

I encounter an error at connection.Open(); and it throws the following exception:

MySql.Data.MySqlClient.MySqlPoolManager' threw an exception.-	
$exception	{System.TypeInitializationException: The type initializer for 'MySql.Data.MySqlClient.MySqlPoolManager' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies,

It looks like I'm missing a file called System.Runtime.Loader with a version 4. And after checking the assets I found that I had this file but it's version is an older 1.0.24212.1. What steps could I take to try to fix this problem?

答案1

得分: 0

我已成功使用@Jason在这里提到的nugget包使程序运行起来。以这种方式连接SQL是不明智的,因为您的程序可能会被反编译,导致服务器信息被窃取。

英文:

I was able to get the program running with the nugget package @Jason mentioned here. It is ill advised to connect to SQL in this manner as your program can be de-compiled and your server information stolen.

huangapple
  • 本文由 发表于 2023年7月31日 22:26:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/76804581.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定