Kopra Posted October 27, 2020 Posted October 27, 2020 (edited) Hi, i am new to C# and rage development, i was trying to follow MySQL tutorial by Outwardly Experience but after starting server i get these warnings: 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. 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. I tried installing System.Security.Permissions in NuGet manager but that did not work, i also tried copying .dlls to runtime folder, still same errors. My dependencies: Any help would be great Tutorial link: https://www.youtube.com/watch?v=1QBj-DO6APM Edited November 16, 2020 by Kopra issue solved
brosiden Posted October 27, 2020 Posted October 27, 2020 Copy the depencdencies into runtime folder and then add them to your project's dependencies. 1
Kopra Posted October 27, 2020 Author Posted October 27, 2020 (edited) I already tried that, still same errors. Here are some more info: I get these warnings when i try to execute my MySQL function in Main.cs ResourceStart public: MySQL.MySQL.InitConnection(); MySQL.cs : using System; using System.IO; using System.Reflection; using MySql.Data.MySqlClient; using GTANetworkAPI; namespace Project.MySQL { class MySQL { public static bool IsConnectionSetUp = false; public static MySqlConnection conn; public String Host { get; set; } public String Username { get; set; } public String Password { get; set; } public String Database { get; set; } public MySQL() { this.Host = "localhost"; this.Username = "root"; this.Password = "root"; this.Database = "test_db"; } public static void InitConnection() { String FilePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "SQLInfo.json"); MySQL sql = new MySQL(); if(File.Exists(FilePath)) { NAPI.Util.ConsoleOutput("File found! Loading data...."); String SQLData = File.ReadAllText(FilePath); sql = NAPI.Util.FromJson<MySQL>(SQLData); NAPI.Util.ConsoleOutput(SQLData.ToString()); 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()); } } else // File not found { NAPI.Util.ConsoleOutput("File not found! Creating default data file...."); String SQLData = NAPI.Util.ToJson(sql); using (StreamWriter writer = new StreamWriter(FilePath)) { writer.WriteLine(SQLData); } NAPI.Util.ConsoleOutput("File has been created. Loading data...."); InitConnection(); } } } } Edited October 27, 2020 by Kopra
Kopra Posted October 30, 2020 Author Posted October 30, 2020 Anyone? I tried everything there is on google... Here is my .csproj file: <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>netcoreapp3.1</TargetFramework> </PropertyGroup> <ItemGroup> <PackageReference Include="gtanetwork.api" Version="1.1.0-DP1-2" /> <PackageReference Include="MySql.Data" Version="8.0.22" /> <PackageReference Include="RAGEMP-Bootstrapper" Version="1.1.3" /> <PackageReference Include="System.Drawing.Common" Version="4.7.0" /> <PackageReference Include="System.Drawing.Primitives" Version="4.3.0" /> </ItemGroup> </Project>
Kopra Posted October 30, 2020 Author Posted October 30, 2020 Okay i fixed it. Switching from MySql.Data to MySqlConnector 1.0.1 did the trick. https://www.nuget.org/packages/MySqlConnector/ Big thanks to: https://stackoverflow.com/questions/64609477/could-not-load-file-or-assembly-problem-with-mysql-data-in-net-core?noredirect=1#comment114253856_64609477 1
Recommended Posts