【发布时间】:2021-02-12 23:32:21
【问题描述】:
我正在使用 Visual Studio Code 并尝试使用 C# 为 GTA 5 RAGEMP 编写脚本,我对 C# 相当陌生,并且一切顺利,直到我尝试使用来自 oracle 的 MySQL.Data 创建 MySQL 连接器。 在我的尝试中 - 抓住我得到这个:
System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Drawing.Common, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.'
String SQLConnection = $"SERVER={sql.Host};PASSWORD={sql.Password};UID={sql.Username};DATABASE={sql.Database}";
conn = new MySqlConnection(SQLConnection);
try
{
conn.Open();
NAPI.Util.ConsoleOutput("MySQL connection is up!");
IsConnectionSetUp = true;
}
catch(Exception ex)
{
NAPI.Util.ConsoleOutput(ex.ToString());
}
我在服务器控制台输出中得到了这个:
Could not load file or assembly 'System.Security.Permissions, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
Could not load file or assembly 'System.Drawing.Common, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
Could not load file or assembly 'System.Drawing.Common, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
Could not load file or assembly 'System.Drawing.Common, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
Could not load file or assembly 'System.Drawing.Common, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
这在 VSC 控制台输出中:
Exception thrown: 'System.IO.FileNotFoundException' in MySql.Data.dll
Exception thrown: 'System.IO.FileNotFoundException' in System.Private.CoreLib.dll
An exception of type 'System.IO.FileNotFoundException' occurred in System.Private.CoreLib.dll but was not handled in user code
Could not load file or assembly 'System.Drawing.Common, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
我将 MySQL/Connector 中的所有内容复制到我的运行时文件夹,我尝试使用 NuGet 下载 System.Drawing.Common 和 System.Security.Permissions,我尝试手动将 .DLL 添加到项目依赖项中,但没有任何效果。
【问题讨论】: