?
Solved

Could not load file or assembly 'MySql.Data,

Posted on 2010-01-12
2
Medium Priority
?
1,183 Views
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 5.2.5.0.  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 5.1.1.0.   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=5.1.1.0, 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: 174.55.147.179
    User:  
    Is authenticated: False
    Authentication Type:  
    Thread account name: NT AUTHORITY\NETWORK SERVICE

---- vb code that I think I need to compile with 5.2.5.0 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
                  Get
                        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
                              Conn.Open()
                              Using DR As MySqlDataReader = Cmd.ExecuteReader()
                                    If DR.Read
                                          System.Web.HttpContext.Current.Response.ClearContent()
                                          System.Web.HttpContext.Current.Response.ClearHeaders()
                                          System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "inline; filename=" & DR("fileName"))
                                          System.Web.HttpContext.Current.Response.ContentType = DR("fileType").ToString()
                                          System.Web.HttpContext.Current.Response.BinaryWrite(DR("fileData"))
                                          GC.Collect()
                                    End If
                              End Using
                        End Using
                  End Using
            End Sub
      
      End Class
      
End Namespace
0
Comment
Question by:super__g
[X]
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
2 Comments
 
LVL 57

Expert Comment

by:HainKurt
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...
0
 

Accepted Solution

by:
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.
0

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