Rohit Singh

Rohit Singh

  • NA
  • 749
  • 88.3k

Could not load file or assembly 'MySql.Data'

Jul 10 2018 6:14 AM
 I'm facing this error in my WebApi project which is working very well on local IIS but when I deployed my project on my Live Server I'm facing this issue Could not load file or assembly 'MySql.Data' or one of its dependencies. I'm working with MySql Database and added all the related dependencies in web.config file but nothing seems to be working out for me.
 
Error:  Could not load file or assembly 'MySql.Data' or one of its dependencies. The system cannot find the file specified.
 
my Web.Config file
 
 
  1. <?xml version="1.0" encoding="utf-8"?>  
  2.     <!--   
  3.       http://go.microsoft.com/fwlink/?LinkId=301879 
  4.       -->  
  5.     <configuration>  
  6.       <configSections>    
  7.         <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />  
  8.       </configSections>  
  9.       <connectionStrings>  
  10.         <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-IntranetApiDemo-20180709022909.mdf;Initial Catalog=aspnet-IntranetApiDemo-20180709022909;Integrated Security=True" providerName="System.Data.SqlClient" />          
  11. <add name="DBCS" connectionString="Server=14.192.18.129;userid=admin;password=pwd; Database=db; convert zero datetime=True; default command timeout=0; SslMode = none" providerName="System.Data.MySqlClient" />  
  12.       </connectionStrings>  
  13.       <appSettings></appSettings>  
  14.       <system.web>  
  15.         <authentication mode="None" />  
  16.         <compilation debug="true" targetFramework="4.5.2" />  
  17.         <httpRuntime targetFramework="4.5.2" />  
  18.       </system.web>  
  19.       <system.webServer>  
  20.         <modules>  
  21.           <remove name="FormsAuthentication" />  
  22.         </modules>  
  23.         <handlers>  
  24.           <remove name="ExtensionlessUrlHandler-Integrated-4.0" />  
  25.           <remove name="OPTIONSVerbHandler" />  
  26.           <remove name="TRACEVerbHandler" />  
  27.           <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />  
  28.         </handlers>  
  29.       </system.webServer>  
  30.       <runtime>  
  31.         <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">  
  32.           <dependentAssembly>  
  33.             <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" />  
  34.             <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />  
  35.           </dependentAssembly>  
  36.           <dependentAssembly>  
  37.             <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" />  
  38.             <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />  
  39.           </dependentAssembly>  
  40.           <dependentAssembly>  
  41.             <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" />  
  42.             <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />  
  43.           </dependentAssembly>  
  44.           <dependentAssembly>  
  45.             <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" />  
  46.             <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />  
  47.           </dependentAssembly>  
  48.           <dependentAssembly>  
  49.             <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />  
  50.             <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />  
  51.           </dependentAssembly>  
  52.           <dependentAssembly>  
  53.             <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />  
  54.             <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />  
  55.           </dependentAssembly>  
  56.           <dependentAssembly>  
  57.             <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />  
  58.             <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />  
  59.           </dependentAssembly>  
  60.           <dependentAssembly>  
  61.             <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />  
  62.             <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />  
  63.           </dependentAssembly>  
  64.           <dependentAssembly>  
  65.             <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />  
  66.             <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />  
  67.           </dependentAssembly>  
  68.           <dependentAssembly>  
  69.             <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />  
  70.             <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />  
  71.           </dependentAssembly>    
  72.          <dependentAssembly>  
  73.             <assemblyIdentity name="MySql.Data.MySqlClient" publicKeyToken="c5687fc88969c44d" />  
  74.             <bindingRedirect oldVersion="1.0.0.0-6.10.7.0" newVersion="6.10.7.0" />  
  75.           </dependentAssembly>      
  76.         </assemblyBinding>  
  77.       </runtime>  
  78.       <entityFramework>  
  79.        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>  
  80.         <providers>  
  81.             <provider invariantName="MySql.Data.MySqlClient"  
  82.                 type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.10.7.0"/>  
  83.             <provider invariantName="System.Data.SqlClient"  
  84.                 type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>  
  85.         </providers>  
  86.       </entityFramework>  
  87.       <system.codedom>  
  88.         <compilers>  
  89.           <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />  
  90.           <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />  
  91.         </compilers>  
  92.       </system.codedom>  
  93.     </configuration>  

As you can see in my code above the verion of MySql.Data.Entity.EF6 (Version=6.10.7.0) matches with the MySql.Data.MySqlClient Version =6.10.7.0.

Is there anything which is missing in Web.Config file. Please help me to solve this problem.

Thanks.

 

Answers (2)