我尝试部署一个简单的 wcf 服务,该服务与 mysql5.7 数据库连接,通过错误将其服务器上,但是当我运行到我的本地机器时,相同的应用程序运行正常(我的本地机器也有一个 mysql5.7 数据库)。 7 数据库)我不知道为什么会出现这个错误。
我已经准备好添加 Mysql.Data.dll 6.9.9.0;
错误是:
服务器在处理请求时遇到错误。异常信息是
'Could not load file or assembly 'MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The system cannot find the file specified.'. See server logs for more details
.异常堆栈跟踪是:
at MyServiceBecouseError.MyNameService.nameInput(String input, String inputwo) at SyncInvokenameInput(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
我的 web.config 文件:
<configuration>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="mexBehaviors">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="MyServiceBecouseError.MyNameService" behaviorConfiguration="mexBehaviors">
<endpoint address="" binding="webHttpBinding" behaviorConfiguration="web" contract="MyServiceBecouseError.IMyNameService"/>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<directoryBrowse enabled="true"/>
</system.webServer>
<system.web>
<compilation debug="true"/>
</system.web>
<runtime>
<dependentAssembly>
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0" newVersion="6.9.9.0" />
</dependentAssembly>
</runtime>
</configuration>
应用程序下连接数据库和向数据库插入数据的简单方法;
public class MyNameService : IMyNameService
{
public string nameInput(string input, string inputwo)
{
string myDataString = "Server=localhost;Database=foo;Uid=root;Pwd=qwerty;";
MySqlConnection connection = new MySqlConnection(myDataString);
MySqlCommand cmd;
connection.Open();
try
{
cmd = connection.CreateCommand();
cmd.CommandText= "INSERT INTO foo.footable (id,name,lastName) VALUES (@id,@name,@lastName)";
cmd.Parameters.AddWithValue("@id", int.Parse(3.ToString()));
cmd.Parameters.AddWithValue("@name", input);
cmd.Parameters.AddWithValue("@lastName", inputwo);
cmd.ExecuteNonQuery();
connection.Close();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
return "hello pushpam";
}
}
}
最佳答案
.net framework 版本是否与 IIS 应用程序池相符?
关于c# - 异常信息是 'Could not load file or assembly ' MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43160788/