Reputation: 20068
I am using FluentNHibernate and during the configuration phase I am getting the following error:
Here is the configuration:
public static ISessionFactory CreateSessionFactory()
{
return
Fluently.Configure().Database(
MsSqlConfiguration.MsSql2000.ConnectionString(
c => c.FromConnectionStringWithKey("HighOnCodingConnectionString")))
.Mappings(m =>
m.FluentMappings.AddFromAssemblyOf())
.BuildSessionFactory();
}
And here is the error:
[failure] when_instantiating_a_session_factory.should_be_able_to_create_a_session_factory TestCase 'when_instantiating_a_session_factory.should_be_able_to_create_a_session_factory' failed: The type initializer for 'NHibernate.Cfg.Configuration' threw an exception. System.TypeInitializationException Message: The type initializer for 'NHibernate.Cfg.Configuration' threw an exception. Source: NHibernate StackTrace: at NHibernate.Cfg.Configuration..ctor() c:\FluentNHibernate\src\FluentNHibernate\Cfg\FluentConfiguration.cs(25,0): at FluentNHibernate.Cfg.FluentConfiguration..ctor() c:\FluentNHibernate\src\FluentNHibernate\Cfg\Fluently.cs(16,0): at FluentNHibernate.Cfg.Fluently.Configure() C:\Projects\highoncodingmvc\src\highoncoding\src\HighOnCoding.BusinessObjects\Factories\SessionFactory.cs(17,0): at HighOnCoding.BusinessObjects.Factories.SessionFactory.CreateSessionFactory() C:\Projects\highoncodingmvc\src\highoncoding\src\HighOnCoding.TestSuite\Configuration\TestFluentNHiberate.cs(17,0): at HighOnCoding.TestSuite.Configuration.when_instantiating_a_session_factory.should_be_able_to_create_a_session_factory() Inner Exception System.IO.FileLoadException Message: The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Source: NHibernate StackTrace: at NHibernate.Cfg.Configuration..cctor()
Here is the log information from FusionLog thing:
* Assembly Binder Log Entry (6/21/2009 @ 12:49:38 PM) *
The operation failed. Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll Running under executable C:\Projects\highoncodingmvc\src\highoncoding\src\HighOnCodingConsole\bin\Debug\HighOnCodingConsole.exe --- A detailed error log follows.
=== Pre-bind state information === LOG: User = D9SKQBG1\AzamSharp LOG: DisplayName = NHibernate.XmlSerializers, Version=2.0.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL (Fully-specified) LOG: Appbase = file:///C:/Projects/highoncodingmvc/src/highoncoding/src/HighOnCodingConsole/bin/Debug/ LOG: Initial PrivatePath = NULL LOG: Dynamic Base = NULL LOG: Cache Base = NULL LOG: AppName = NULL
LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Projects\highoncodingmvc\src\highoncoding\src\HighOnCodingConsole\bin\Debug\HighOnCodingConsole.exe.Config LOG: Using machine configuration file from c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config. LOG: Post-policy reference: NHibernate.XmlSerializers, Version=2.0.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, processorArchitecture=MSIL LOG: GAC Lookup was unsuccessful. LOG: Attempting download of new URL file:///C:/Projects/highoncodingmvc/src/highoncoding/src/HighOnCodingConsole/bin/Debug/NHibernate.XmlSerializers.DLL. LOG: Attempting download of new URL file:///C:/Projects/highoncodingmvc/src/highoncoding/src/HighOnCodingConsole/bin/Debug/NHibernate.XmlSerializers/NHibernate.XmlSerializers.DLL. LOG: Attempting download of new URL file:///C:/Projects/highoncodingmvc/src/highoncoding/src/HighOnCodingConsole/bin/Debug/NHibernate.XmlSerializers.EXE. LOG: Attempting download of new URL file:///C:/Projects/highoncodingmvc/src/highoncoding/src/HighOnCodingConsole/bin/Debug/NHibernate.XmlSerializers/NHibernate.XmlSerializers.EXE. LOG: All probing URLs attempted and failed.
Upvotes: 4
Views: 13144
Reputation: 1521
I know this is long since resolved, but having had this problem myself today, I found this as my personal solution and thought I'd share the knowledge:
https://forum.hibernate.org/viewtopic.php?p=2399679
From the post:
"My debugger in Visual Studio was set to break on all exceptions, adjusting the exception settings fixed my problem."
Also led me to:
http://www.codewrecks.com/blog/index.php/2008/02/13/sgenexe-and-strongly-named-assemblies/
"After some search I found that the xxxx.XmlSerializers assembly is a pregenerated assembly that the xmlserializers looks for before attempting to generate one at runtime..."
Upvotes: 2
Reputation: 1499950
Looks like you've compiled against one version of an assembly, but at execution time it's finding another and complaining. I suggest you turn on Fusion logging to work out what's going on - in particular, the exact assembly which is causing problems!
Upvotes: 2