Could not load file or assembly 'MySql.Data,

Posted on 2010-01-12
Medium Priority
Last Modified: 2013-11-25
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: http://test.xxxxxx.com/bo/file.ashx?FileID=223 
    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
Question by:super__g
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 57

Expert Comment

ID: 26300708
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...

Accepted Solution

super__g earned 0 total points
ID: 26310515
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.

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question