异常消息是“无法加载文件或程序集' MySql.Data,Version = 6.9.9.0,Culture = neutral,PublicKeyToken = c5687fc88969c44d'?

时间:2017-04-01 18:56:45

标签: c# mysql asp.net database wcf

我尝试部署一个简单的wcf服务,该服务与mysql5.7数据库连接,通过错误切断它,但同样的应用程序,当我运行到我的本地机器它工作正常(我的本地机器也有一个mysql5。 7数据库)我不知道为什么会出现这个错误。

我已准备好添加了Mysql.Data.dll 6.9.9.0;

错误是:

服务器在处理请求时遇到错误。

是异常消息
  

'无法加载文件或程序集' MySql.Data,Version = 6.9.9.0,   Culture = neutral,PublicKeyToken = c5687fc88969c44d'或其中一个   依赖。系统找不到指定的文件。'。见服务器   日志了解更多详情

。异常堆栈跟踪是:

  

at MyServiceBecouseError.MyNameService.nameInput(String input,String   inputwo)在SyncInvokenameInput(Object,Object [],Object [])at   System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(对象   实例,对象[]输入,对象[]&输出)   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";
        }

    }
}

1 个答案:

答案 0 :(得分:0)

.net框架版本是否与IIS应用程序池相符?