c# - 异常信息是 'Could not load file or assembly ' MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d'?

标签 c# mysql asp.net database wcf

我尝试部署一个简单的 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/

相关文章:

asp.net - 在asp.net中绘制带有声音的图形

c# - 从现有的 visual studio 项目中删除未使用的 js 和 css 文件

c# - 这种将字符串拆分为数组的扩展方法还可以如何参数化?

c# - 没有 ASP.NET Identity 的 ASP.NET Core 中的 Google 身份验证

c# - 窗体 GUI 视频线程通信

javascript - Angular 错误 - ReferenceError : $modal is not defined

mysql - MySQL 中两个日期时间之间的减号运算符的行为是什么?

javascript - 从代码隐藏中禁用 RadioButtonList 并使用 javascript 启用它

c# - 将 vector<unsigned char> {1,2,3} 转换为字符串 "1-2-3"AS DIGITS

MYSQL django测试错误: django. db.utils.InternalError : (7,“重命名时出错