I'm trying to run this line of code for connecting to mysql using csharp and dotnet core 2.1.300 (sdk).
string server = "localhost";
string database = "db";
string uid = "root";
string password = "";
string connectionString;
connectionString = "SERVER=" + server + ";" + "DATABASE=" + database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
connection = new MySqlConnection(connectionString);
connection.Open();
But last line will raise an exception that I cannot understand what goes wrong to resolve it. running dll of project using dotnet shows me this:
dotnet :
At line:1 char:1
+ dotnet C:\Users\foo\bar\project ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Unhandled Exception:
Cannot print exception string because Exception.ToString() failed.
I tried recommendations by posts like this similar question and added System.Runtime.Serialization.Primitives
assembly to my references in VS 2017 but it did not help.
I'm modifying this csharp project actually, so that it write its output to a database. https://github.com/vcsjones/AuthenticodeLint
Changing the MySqlException to Exception will result in this output:
Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'System.Drawing.Common, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr*
methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[]
typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly&
lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean
mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean&
ctorHasParameters, Boolean& isVarArg)
at System.Reflection.CustomAttribute.IsCustomAttributeDefined(RuntimeModule decoratedModule, Int32 decoratedMetadataToken,
RuntimeType attributeFilterType, Int32 attributeCtorToken, Boolean mustBeInheritable)
at System.Reflection.CustomAttribute.IsDefined(RuntimeType type, RuntimeType caType, Boolean inherit)
at System.Diagnostics.StackTrace.ShowInStackTrace(MethodBase mb)
at System.Diagnostics.StackTrace.ToString(TraceFormat traceFormat)
....