2
votes

I'm trying to follow this tutorial, but VS debugger keep asking me for a file named FluentConfiguration.cs when it gets to this line:

return Fluently.Configure()
    .Database(MySQLConfiguration.Standard
    .ConnectionString(c => c
        .Server("localhost")
        .Database("test")
        .Username("root")
        .Password("w1e2a3r4")))
    .Mappings(m => m
        .AutoMappings.Add(model))
    .ExposeConfiguration(BuildSchema)
        .BuildSessionFactory();  

All my code is completely identical to the tutorial's except for this line (I'm using MySql). I triple checked the parameters and it should be ok..
What I get is a dialog box asking me to locate FluentConfiguration.cs, and when it fails to find it it gives:

An invalid or incomplete configuration was used while creating a SessionFactory.    
Check PotentialReasons collection, and InnerException for more detail.

I tried copying this file from here, but this didn't work as well.

What am I missing out on here?
Technical info- I'm using VS 2010 express, ASP.NET MVC3, MySQL server 5.5 and connector: 6.3.6

Edit:
This is the inner exception's message:
Could not create the driver from NHibernate.Driver.MySqlDataDriver, NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4.

Edit 2:
Now I'm getting "checksum doesn't match:
Locating source for 'd:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs'. Checksum: MD5 {94 f4 4c 43 49 bd 48 fb 9a d7 b2 fc 5 e1 4e d8} Determining whether the checksum matches for the following locations: 1: C:\Users\Oren\Desktop\FluentConfiguration.cs Checksum: MD5 {84 33 30 45 11 da 3d 40 8e 2d 3c a9 e 7c cc 14} Checksum doesn't match. The file 'd:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs' does not exist. Looking in script documents for 'd:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs'... Looking in the projects for 'd:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs'. The file was found in a project: 'C:\Users\Oren\Desktop\FluentConfiguration.cs'. Determining whether the checksum matches for the following locations: 1: C:\Users\Oren\Desktop\FluentConfiguration.cs Checksum: MD5 {84 33 30 45 11 da 3d 40 8e 2d 3c a9 e 7c cc 14} Checksum doesn't match. Looking in directory 'C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\vc7\atlmfc'... Looking in directory 'C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\vc7\crt'... Looking in directory 'C:\Users\Oren\Desktop\'... The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: d:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs. The debugger could not locate the source file 'd:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs'.

3
I suspect your specific error is due NHibernate not being able to resolve the Mysql.Data assembly (which is the ADO provider for Mysql). Try adding this to your project references path, or (less preferentially) putting it into the working directory of your binariesfostandy
Thanks for your comment, I think that made me advance a little, but problem isn't solved yet. PLEASE refer to my second edit. Thanks.Oren A

3 Answers

1
votes

Copy-pasted the fluent hibernate dlls and pdbs again, and problem was solved.

1
votes

to resolve this issue. I had to add a reference to NHibernate.ByteCode.Castle.dll

0
votes

The debugger is asking for one of the source files for Fluent nHibernate. You could download this because it is open source and debug it in detail, though the answer is in the InnerException.

This is probably due to a class that has not been mapped or possibly properties not being marked as virtual, or simply a database table that does not follow the standard FNH conventions. You need to get to the InnerException and read what it says as nHibernate exceptions are generally very helpful. I had plenty of trouble getting to the inner exception when I was trying to run unit tests running MSTest. I switched back to nUnit and had no trouble.

Another very useful thing to do is to output your .hbm files during the config process (FNH generates these for you behind the scenes). See Generate XML mappings from fluent Nhibernate for details. Note: I usually add a compiler directive to ensure that I only output the .hbm files in debug builds.