1

I've recreated the Northwind Spring/NHibernate example that comes with Spring.NET, but with MySQL rather than SQLServer. I've almost got it working I think, but I'm getting this when I try to use Hibernate to load something from the database

A first chance exception of type 'System.IO.FileNotFoundException'
occurred in mscorlib.dll NHibernate.Util.ReflectHelper: 
ERROR lambda_method - Could not load type
MySql.Data.MySqlClient.MySqlCommand, MySql.Data.
System.IO.FileNotFoundException: Could not load file or assembly
'MySql.Data' or one of its dependencies. 
The system cannot find the file specified. 
File name: 'MySql.Data'    

Every project (DAO, Service, Web) has a reference to the MySQL.Data DLL so I'm a bit unsure what's going on.

Can anyone help me please?

Ken White
  • 123,280
  • 14
  • 225
  • 444
Richard
  • 1,731
  • 2
  • 23
  • 54

1 Answers1

0

Make sure that MySQL.Data.dll actually got copied to the output folder. And that you are using right platform (x32 vs x64 bit) and right version of .NET (2,3,3.5 vs 4). If everyhing seems fine, enable Fusion Logging and take a look at this article:

For FileNotFoundException: At the bottom of the log will be the paths that Fusion tried probing for this assembly. If this was a load by path (as in Assembly.LoadFrom()), there will be just one path, and your assembly will need to be there to be found. Otherwise, your assembly will need to be on one of the probing paths listed or in the GAC if it's to be found.

You may also get this exception if an unmanaged dependency or internal module of the assembly failed to load. Try running depends.exe on the file to verify that unmanaged dependencies can be loaded. Note that if you re using ASP.NET, the PATH environment variable it's using may differ from the one the command line uses. If all of them could be loaded, try ildasm.exe on the file, double-click on "MANIFEST" and look for ".file" entries. Each of those files will need to be in the same directory as the manifest-containing file.

Community
  • 1
  • 1
Dmitry
  • 17,078
  • 2
  • 44
  • 70
  • Thanks (again). Hmmm, I've tried a couple of DLLs for MySQL now and they are being copied to the debug/bin folder (that Fusion tells me it's looking in) of my project so I think they are correct. I'm not getting any specific errors in my log files from NHibernate, but when I try to do a lookup in my Dao, it's saying that the session is null, so I'm guessing my SessionFactory isn't set up correctly. But it's set as a property in my spring config. Arghhhhh... – Richard Sep 17 '11 at 12:53
  • Open another question if you have a different problem now. – Dmitry Sep 17 '11 at 17:05
  • 1
    It's ok, its working great now. I posted a more complete answer here http://forum.springframework.net/showthread.php?9456-NHibernate-SessionFactory-problems. Feels so good to be using Hibernate and Spring again. Since moving to .NET they've had me coding SQL statements into my DAOs urgh...! – Richard Sep 17 '11 at 19:09