I'm extremely new to NHibernate so I apologize if I missing something trivial here. I am currently working through a book titled "NHibernate 3 Beginners Guide" from packtpub. I have mostly been following the directions in the book. When I say mostly I have diverged by using MySQL instead of MSSQL and have been using NuGet rather than downloading the binaries by hand.
I am in Chapter 2 at the moment which is the first real coding chapter. In this chapter I am building a simple WPF application to build my database schema through a button click. I have already built some POCO's for the Product
and Category
classes specified in the chapter. Through NuGet I have added the following references:
When I click the button to build my database the following code block is executed:
private const string connString = "string omitted for brevity";
private void btnCreateDatabase_Click(object sender, RoutedEventArgs e)
{
Fluently.Configure().Database(MySQLConfiguration.Standard.ConnectionString(connString))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<ProductMap>())
.ExposeConfiguration(CreateSchema)
.BuildConfiguration();
}
Upon clicking the button I receive the following exception (FileLoadException
):
Outer Exception Message: Could not load file or assembly 'Iesi.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Inner Exceptions Message: Could not load file or assembly 'Iesi.Collections, Version=1.0.1.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Here is the "Fusion Log" if that helps:
=== Pre-bind state information ===
LOG: User = Borealis\Frito
LOG: DisplayName = Iesi.Collections, Version=1.0.1.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
(Fully-specified)
LOG: Appbase = file:///C:/Users/Frito/documents/visual studio 2010/Projects/NH3BeginnersGuide/Chapter2/App/Sample.UI/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\Frito\documents\visual studio 2010\Projects\NH3BeginnersGuide\Chapter2\App\Sample.UI\bin\Debug\Sample.UI.vshost.exe.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 1.0.1.0 redirected to 4.0.0.0.
LOG: Post-policy reference: Iesi.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
LOG: Attempting download of new URL file:///C:/Users/Frito/documents/visual studio 2010/Projects/NH3BeginnersGuide/Chapter2/App/Sample.UI/bin/Debug/Iesi.Collections.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
I have tried the following and now am at a bit of a loss:
I have two questions:
Thanks in advance!
Holy poopers this drove me nuts. I found that an app.config
was created at some point, presumably as I was messing with something. In the app.config
I found the following:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Iesi.Collections" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Commenting out the Runtime
element, rebuilding and running allowed the button above to function properly. I'm not sure what I did to cause this to get generated but I'm glad I found it. Thanks all for your efforts to assist and thanks for the upvote on the question!
Iesi.Collections 4.0 is a heavily modified version targeting .Net 4.0, for use with a future NHibernate 4.0.
Unfortunately Nuget packages for NHibernate versions up to and including 3.3.1 don't specify an upper bound for the Iesi dependency. With NHibernate 3.3.2 this was changed, to explicitly forbid Iesi version 4 or higher. So if you update to NH 3.3.2 via NuGet, I expect it to resolve the Iesi dependency to a 3.x version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With