Could not load file or assembly 'MySql.Data,

I'm getting the following error in a web application of mine.  I was recently given a website that uses MySQL and .Net.  This site uses MySQL to store data and images that the users can change.  I am able to read/insert/change text values in the database but I get the error below when I try to insert an image.  The web.config and dll in the bin directory are  I suspect that there is a dll that is used for the control panel function that I am referring because I cannot find any reference of version   There are a few .vb files that were supplied but I do not know enough to compile.   Any help to point me in the right direction would be greatly appreciated.

Exception information:
    Exception type: FileLoadException
    Exception message: Could not load file or assembly 'MySql.Data, Version=, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Request information:
    Request URL: 
    Request path: /bo/file.ashx
    User host address:
    Is authenticated: False
    Authentication Type:  
    Thread account name: NT AUTHORITY\NETWORK SERVICE

---- vb code that I think I need to compile with MySQL --
Imports System
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Drawing.Drawing2D
Imports System.Web
Imports System.Web.HttpContext
Imports Microsoft.VisualBasic
Imports MySql.Data.MySqlClient

Namespace BEMS
      Public Class FileHandler
            Implements IHttpHandler
            Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
                        Return True
                  End Get
            End Property
            Public Sub New()
            End Sub
            Public Sub ProcessRequest(ByVal context As HttpContext) Implements System.Web.IHttpHandler.ProcessRequest
                  dim Settings As New GlobalSettings()
                  Using Conn As New MySqlConnection(Settings.MySqlConnectionString)
                        Using Cmd As New MySqlCommand("SELECT fileName, fileData, fileType FROM tblfile WHERE fileID=?fileID AND fileSecure=0 AND fileDeleted=0", Conn)
                              With Cmd.Parameters
                                    .Add(New MySqlParameter("?fileID",HttpContext.Current.Request.QueryString("fileID")))
                              End With
                              Using DR As MySqlDataReader = Cmd.ExecuteReader()
                                    If DR.Read
                                          System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "inline; filename=" & DR("fileName"))
                                          System.Web.HttpContext.Current.Response.ContentType = DR("fileType").ToString()
                                    End If
                              End Using
                        End Using
                  End Using
            End Sub
      End Class
End Namespace
Who is Participating?
super__gConnect With a Mentor Author Commented:
Turns out I needed to open the .vb files and make some changes,  either adding references and copying classes from other vb files.  Once I did that I was able to compile the dlls successfully.

I tried the suggestion of removing and adding the MySQL but that didn't resolve the issue.
HainKurtSr. System AnalystCommented:
do you have anything in web.config

if yes, try to remove it, remove the reference, delete the interop or dll in bin folder and try to add reference again...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.