我试图在C#中的mySQL DB上执行INSERT语句:
MySqlConnection connection = new MySqlConnection("SERVER=" + _dbConnection + ";" +
"DATABASE=" + _dbName + ";" +
"PORT=" + _dbPort + ";" +
"UID=" + _dbUsername + ";" +
"PASSWORD=" + _dbPassword + ";");
MySqlDataAdapter adapter;
DataSet dataset = new DataSet();
command = new MySqlCommand();
command.Connection = connection;
command.CommandText = "INSERT INTO plugins (pluginName, enabled) VALUES (@plugin,@enabled)";
command.Parameters.AddWithValue("@name", "pluginName");
command.Parameters.AddWithValue("@enabled", false);
adapter = new MySqlDataAdapter(command);
adapter.Fill(dataset);
Run Code Online (Sandbox Code Playgroud)
插件表由两列组成:pluginName(varchar(50))和enabled(boolean)。
失败并显示以下错误:mysql在命令执行期间遇到致命错误。有什么想法为什么会失败?
我认为这是一个相当复杂的问题.我有一个C#应用程序,它使用反射的插件架构.应用程序加载插件dll,用户可以启用/禁用它们.启用插件后,主应用程序会启动一个线程来运行插件.在许多情况下,插件可能有多个自己的线程.当我想禁用一个插件时,我正在调用Thread.Abort().这似乎会破坏为插件创建的初始线程,但插件创建的任何其他线程都会继续运行.有没有更好的方法来阻止所有相关的插件线程和主线程?
谢谢.
我在远程计算机上托管了WCF服务.在我的本地机器上,我有一个WPF应用程序和一个Windows服务,我希望能够连接到WCF服务.WPF应用程序连接和通信很好,但由于某种原因,Windows服务将无法连接.它们的app.config文件是相同的,并且连接的代码在两者中是相同的.是否有任何理由为什么Windows服务无法连接?
以下是我得到的例外情况:
套接字连接已中止.这可能是由于处理消息的错误或远程主机超出接收超时或基础网络资源问题引起的.本地套接字超时为'00:01:14.9900000'.
关于这一点的奇怪之处在于异常是在5秒内抛出,而不是在超时设置为1:15之后抛出.
这是app.config:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="ServiceIP" value="127.0.0.1"/>
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="lib" />
</assemblyBinding>
</runtime>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBindingEndpoint" closeTimeout="00:01:00"
openTimeout="00:00:10" receiveTimeout="00:10:00" sendTimeout="00:01:15"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288"
maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:8731/WCFService/" binding="netTcpBinding"
bindingConfiguration="NetTcpBindingEndpoint" contract="WCFService.IWCFService"
name="NetTcpBindingEndpoint">
<identity>
<dns value="localhost" /> …Run Code Online (Sandbox Code Playgroud) The endpoint at 'http://localhost:8731/Design_Time_Addresses/WCF/WCFService/' does not have a Binding with the None MessageVersion. 'System.ServiceModel.Description.WebHttpBehavior' is only intended for use with WebHttpBinding or similar bindings.
Run Code Online (Sandbox Code Playgroud)
这是我尝试启动WCF服务时遇到的错误.我在这里阅读了关于绑定错误的每篇文章,但它们都有点不同,我无法弄明白.这是我的app.config:
<system.serviceModel>
<services>
<service name="WCF.WCFService">
<endpoint address="" binding="wsHttpBinding" contract="WCF.IWCFService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
bindingConfiguration=""
contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/Design_Time_Addresses/WCF/WCFService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior>
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
我在Windows服务中托管我的WCF服务,如果这有所不同.MY End的目标是使用winforms应用程序来使用WCF服务.当我在VS中运行WCF服务时,它可以工作,但是当我将配置添加到windows服务app.config并尝试用它启动WCF服务时,我收到错误.任何帮助都会很棒.
我遇到以下情况:我有一个 Windows 服务,它使用 Microsoft AddIn Framework 将许多外部 .dll 作为 AddIn 加载。每个 AddIn .dll 都位于“AddIns”目录内各自的目录中,该目录位于包含服务 exe 的目录中。每个 AddIn .dll 都引用一个公共程序集,该程序集基本上是 AddIn 的 API。我把它放在服务目录中。我遇到的问题是 API .dll 也必须位于每个 AddIn 目录中,否则我会收到错误:
调用目标已引发异常。- System.IO.FileNotFoundException:无法加载文件或程序集“OSAE.API,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null”或其依赖项之一。该系统找不到指定的文件。
我还尝试将此程序集添加到 GAC 中,该程序集似乎将其放在C:\Windows\Microsoft.NET\assembly\GAC_MSIL\OSAE.API\v4.0_1.0.0.0__f47a6446f36f79f7,但这似乎没有帮助。
我怎样才能告诉插件在特定目录中查找程序集或将其设置在可以全局访问的位置?