Fluent NHibernate and NHibernate version issue - nhibernate

Could not load file or assembly 'NHibernate, Version=3.2.0.2002, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The system cannot find the file specified.

This could be caused by a number of things, but the most probable cause is that your start up project does not reference the assembly 'NHibernate, Version=3.2.0.2002, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' although other assemblies you have referenced use the assembly.
Add the assembly to the start up project and you shall be fine.
And please try to ask questions in a better manner.

It seems FHN has not a build for NH 3.2 yet, because it's in RC state right now.
So you can use asm binding redirect for now.

Related

NServiceBus appears to take a hard reference to version 2.0.0.0 via Ionic.Zip.dll

I'm using NServiceBus in a complicated solution (150+ projects, many of them use NSB). Up until last night, when I couldn't stand it anymore, every project had it's own target directories (./bin/debug and ./bin/release). Because of the dependencies between my projects, I was building and rebuilding the same binaries many times over, so we decided to change to a shared output directory for the whole thing, which dramatically improves the build time of the solution. So far so good...
However, when I tried to start up my project, it fails to start giving me the error:
Warning 1 : Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets 1697 5 My.Assembly.Goes.Here
Uh, oh. So, I dutifully turn up the log verbosity, clean and rebuild the whole mess, to find this in the log output:
30>------ Build started: Project: My.Assembly.Goes.Here, Configuration: Debug Any CPU ------
28>Building with tools version "12.0".
<Lots of stuff omitted...>
28> There was a conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes".
28> "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" was chosen because it was primary and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes" was not.
28> References which depend on "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\mscorlib.dll].
<etcetera...>
Out comes Dependency Walker (great tool, btw). OK, so what's depending on the old 2.0 framework? Look for every reference to mscorlib and ... One of these things is not like the other...
NServiceBus.Hosting.Azure takes a dependency on Ionic.Zip.dll which, in turn, takes a dependency on the 2.0.0.0 version of mscorlib.dll. Ouch. FWIW, the version of NServiceBus.Hosting.Azure that does so is 5.3.2.0.
This looks to me to be similar to the issue here: https://github.com/Particular/NServiceBus/issues/664
Can I get around this with an Assembly Binding Redirect? Is there some way for me to tell NSB to tell Ionic.Zip.dll that the 4.0.0.0 version of mscorlib.dll is fine, thank you very much?
Or is this an NSB bug?
Thanks in advance.
A binding redirect on mscorlib should work in my opinion, or you could try a binding redirect on a newer version of dotnetziplib (Ionic) that targets 4.0

Using ILMerge to merge multiple dll files into one dll, some of the dll files cannot be used

I have a library project that is working properly, and it is using the fluent nhibernate, npgsql, enyim.caching dll files, I use the ilmerge to combine all files into one, and after that the merged dll file is referenced by another project, then it doesn't work, it complains cannot find assembly of enyim.caching.dll, and the missing configuration of nhibernate
The command I am using for merging is below
ilmerge /targetplatform:v4 /target:library /out:testmerged.dll Release/Enyim.Caching.dll Release/FluentNHibernate.dll Release/Iesi.Collections.dll Release/log4net.dll Release/Mono.Security.dll Release/NHibernate.Caches.SysCache.dll Release/NHibernate.dll Release/Npgsql.dll Release/mylib.dll
The error from the project referencing it:
Message = "'FluentNHibernate.Automapping.IAutoClasslike, testmerged, Version=2.12.0.0, Culture=neutral, PublicKeyToken=null' is missing a parameterless constructor."
Message = "Could not load file or assembly 'Enyim.Caching' or one of its dependencies. The system cannot find the file specified."
I pay attention to those 2 dll files are using the runtime version v2.0.50727, and all files under runtime version v4.0.30319 are working correctly.
So, can you guys give any suggestion how to fix this issue?
Thanks
Ok, finally, I found the solution to enyim.caching.dll
I have to add
<sectionGroup name="enyim.com">
<section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection, testmerged"/>
</sectionGroup>
<section name="memcached" type="Enyim.Caching.Configuration.MemcachedClientSection, testmerged"/>
in my configuration file

Using NServiceBus + StructureMap + MVC5

I'm getting some really weird errors, see the repro here - https://github.com/tonyeung/nservicebus-structuremap-mvc5
A strongly-named assembly is required.
Could not load file or assembly 'NServiceBus, Version=4.1.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.
Unable to find the exported Type's in assembly NServiceBus.Core, Version=4.1.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c. One or more of the assembly's dependencies may be missing. Could not load file or assembly 'Raven.Abstractions, Version=2.0.3.0, Culture=neutral, PublicKeyToken=37f41c7f99471593' or one of its dependencies. The system cannot find the file specified.
for error number 1 - I had the configuration all set to go, but then it says strong name is needed.
for error number 2 - I commented out the configuration (whats i the repro right now), and I get the manifest error.
for error number 3 - not in repro since its my live project - I have structuremap inject an object that handles my message sending - wanted to create a repro for this, but since i can't even get a simple project going, I'm asking for help now.
The reason you having issues is because your MVC project outputs an assembly named "nservicebus.dll" which clashes the NServiceBus.dll assembly.
Rename the assembly of your MVC5 project to something that doesn't clash and then uncomment the code in the global.cs file.

Fluent NuGet messed up

I have a solution with several projects. I changed a couple of references for Fluent nHibernate to NuGet packages (v1.3.0.717). Recently I changed another project and added the current Fluent package, 1.2.0.712 (earlier but current) and my app will build but not run. The current version points to nHibernate v3.1.0.4 but somewhere it clashes with v3.2.9.4000 which the previous version of Fluent referenced.
Inner Exception
{"Could not load file or assembly 'NHibernate, Version=3.1.0.4000, 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)":"
NHibernate, Version=3.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4"}
Exception
Could not load file or assembly 'NHibernate, Version=3.2.0.4000, 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)
What do I do to clean this project up and get it running again?
Just remove all NHibernate/Fluent Nhibernate related packages and run command
Install-Package FluentNHibernate -Version 1.3.0.717
It will install correct package for you.
For some reason this package is not marked as current version. That is why Nuget gives you old one.

Error loading one of the NHibernate dependent dll's

I am building an application using NHibernate. Because I could not add the DLL's of my current version of NHibernate (I cannot add reference when framework 4.0 is target).
I tried to get the latest and greatest of the w.w.w., this is what I have now:
NHibernate.dll (3.2.0.4000)
NHibernate.ByteCode.Castle (3.0.0.4000)
FluentNHibernate.dll (1.2.0.694)
Castle.Core (2.5.2.0)
Castle.Services.Logging.NLogIntegration (2.5.2.0)
Antlr.Runtim (3.1.3.42154)
Iesi.Collections (3.2.0.400)
These I can reference and build my solution with. I know there are some issues with the copying/loading of the dll.s so I made them deployment items.
But run-time I (still) get the following:
NHibernate.Bytecode.UnableToLoadProxyFactoryFactoryException: Unable to load type 'NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle' during configuration of proxy factory class.
Possible causes are:
- The NHibernate.Bytecode provider assembly was not deployed.
- The typeName used to initialize the 'proxyfactory.factory_class' property of the session-factory section is not well formed.
Solution:
Confirm that your deployment folder contains one of the following assemblies:
NHibernate.ByteCode.LinFu.dll
NHibernate.ByteCode.Castle.dll ---> System.TypeLoadException: Method 'IsProxy' in type 'NHibernate.ByteCode.Castle.ProxyFactoryFactory' from assembly 'NHibernate.ByteCode.Castle, Version=3.0.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' does not have an implementation.
Thoughts anyone?
In response to Vijay Gill’s answer I have decided to take a different tack.
NUGet packages, a one-stop shop, and easy updates!
There is a FluentNHibernate package out there. I have installed it but I guess there is something amiss here too:
Test method CoreDatabaseTests.CreateCoreDatabase threw exception:
System.IO.FileLoadException: Could not load file or assembly 'NHibernate, Version=3.2.0.4000, 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) ---> System.IO.FileLoadException: Could not load file or assembly 'NHibernate, Version=3.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.
With NHibernate 3.2 you don't need NHibernate.ByteCode.Castle anymore, which considerably simplifies your dependency tree.
Getting components from various locations in such cases is nto a good idea, you compile everything from scratch. Well that's my experience so far. Fluent NH has not been updated to NH 3.2GA.
I would suggest you to download fluent NH and stick with the version that comes with it OR if you want to be on the bleeding edge, download the sources of fluent NH and compile with references set to latest NH (3.2GA).