Я пытаюсь запустить эту строку кода для подключения к mysql, используя csharp и 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();
Но последняя строка вызовет исключение, что я не могу понять, чтоидет не так, чтобы решить это. Запуск dll проекта с использованием dotnet показывает мне это:
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.
Я попробовал рекомендации по таким постам аналогичный вопрос и добавил сборку System.Runtime.Serialization.Primitives
к моим ссылкам в VS 2017, но это не такПомогите.
Я на самом деле изменяю этот проект csharp, чтобы он записывал свой вывод в базу данных. https://github.com/vcsjones/AuthenticodeLint
Изменение MySqlException на Exception приведет к следующему выводу:
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)
....