which version of fluent nhibernate is compatible with nhibernate 3.2 - nhibernate

i see when i install fluent nhibernate 1.2 from Nuget, it downloads nhibernate 3.1. If i want to use nhibernate 3.2, how would i do that through nuget and it is compatible with fluent nhibernate 1.2 ?

If you use the Nuget Package Manager Console instead of the GUI to get the package (Install-Package FluentNHibernate) you will get version 1.3.0.717 which is compatible with NHibernate 3.2
I tried it and is working fine for me.

Here you can read about plans to release FluentNHibernate for 3.2GA soon and a suggested workaround using attributes
http://groups.google.com/group/fluent-nhibernate/browse_thread/thread/8e782e45ed9ba647
I got my working using
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="NHibernate"
publicKeyToken="aa95f207798dfdb4"
culture="neutral" />
<bindingRedirect oldVersion="3.1.0.4000"
newVersion="3.2.0.4000"/>
</dependentAssembly>
</assemblyBinding>

Currently, the FluentNHibernate package from the offical NuGet package source, depends on NHibernate.Castle 3.1 (currently, there is no newer version yet), which in turn depends on NHibernate 3.1 (the exact version, not 3.1 or higher). Therefore, NuGet infers a dependency on NHibernate 3.1 when installing FluentNHibernate.
So the bottom line is: you can't, until the FluentNHibernate package is updated.
The most practical way around is getting the latest FluentNHibernate source code and building it against NHibernate 3.2. I've tested that and it seems to work just fine. You might even be fine using assembly binding redirects, but I haven't tested that.
Alternatively, you can wait for NHibernate 3.2 to reach GA (final) and FluentNHibernate to catch up, but of course that's not a very satisfying answer.

Related

ASP.NET Core referencing TPL NuGet package Cannot Find File or Assembly System.Threading

I am making a new ASP.NET Core 2.0 project, essentially a Web API. I have to reference several assemblies that are .NET 3.5 assemblies, so I am running this as a .NET Framework project, just using the .NET Core improvements where possible.
The referenced .NET framework 3.5 assembly references TaskParallelLibrary (1.0.2856). And I think that's where my issues are coming in. It's worth noting the Web API worked on its sample endpoints and all worked as expected.
When I run the application and try and use the referenced library, the call fails and I receive the following exception:
Could not load file or assembly 'System.Threading, Version=1.0.2856.102, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'
or one of its dependencies. The system cannot find the file specified.
I have tried several things, including:
Adding an App.configx file to try and force it to target .NET framework 4's System.Threading, on the assumption that that will be available. Inspired by a page I can't find the link for:
Here's the content:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- this is only here for binding redirects -->
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Threading" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Directly adding the TaskTPLLibrary package at that version to the project. So far, it hasn't helped.
Adding the Microsoft.Bcl.Async library to my project. Again, nothing.
Trying to directly import System.Threading from "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETCore\v4.5\System.Threading.dll". I get an error stating "The reference is invalid or unsupported."
I've tried several other things, including re-cloning, cleaning, re-cleaning, swearing vociferously and coming back at it another day, all to no avail.
My reading list includes (on this computer):
https://github.com/dotnet/corefx/issues/26084
Could not load file or assembly System.Threading.Tasks, Version=2.5.19.0
ASP.NET Core 2.0 Site - FileIOException System.Runtime
And probably others that I can't remember
Some additional information as this issue continues:
Creating a .NET Framework ASP.NET MVC app using .NET Framework 4.6.2 with the same underlying library does work. It does it indirectly using an intermediary .NET Framework 3.5 one (just for convenience as much as anything else).
A .NET Framework 4.6.2 Console App that uses the library directly also runs into this problem. So it seems not to be ASP.NET Core itself. I'll change the tags accordingly.
Making the 4.6.2 console use the intermediary 3.5 library doesn't resolve the issue.
Any help in resolving this issue much appreciated.
As there's no reasonable answer forthcoming, I'm assuming that having a .NET 3.5 Framework library referenced that uses the TaskParallelLibrary will in essence mean that using any .NET above 4 will cause this error. Under unspecified conditions. Most of the time.
The only solution to this seems to be rewrite everything to multi-target .NET 3.5 and .NET Standard and have the Standard implementation use the real TPL and have the 3.5 one use the NuGet package.

Version conflict with a dll

I am developing an mvc application that uses Umbraco and NopCommerce.
Umbraco depends on dll called AutoMapper.dll with version 3.0.0.0.
NopCommerce depends on the same dll but with version 3.3.1.0.
So when I add the dll with version 3.0.0.0 then NopCommerce crashes.
When I add the dll with version 3.3.1.0 then Umbraco crashes.
So i somehow need to use the same dll with two different versions.
I have tried to add something like below to the web.config file:
<dependentAssembly>
<assemblyIdentity name="AutoMapper" publicKeyToken="be96cd2c38ef1005" culture="neutral"/>
<codeBase version="3.0.0.0" href="F:\Visual Studio test projects\UmbracoTest\UmbracoTest\bin\AutoMapper3000\AutoMapper.dll"/>
<codeBase version="3.3.1.0" href="F:\Visual Studio test projects\UmbracoTest\UmbracoTest\bin\AutoMapper3310\AutoMapper3310\AutoMapper.dll"/>
</dependentAssembly>
But with no luck.
Have anyone been in the same situation? Any advice on how to solve this?
Thanks! :)
No such luck, Umbraco simply doesn't support Automapper versions > 3.0. See this recent tweet conversation. How tied to NopCommerce are you? There are other options specifically for Umbraco, like Merchello or uCommerce.

upgrading NHibernate and NHibernate Validator w/ Nuget

As of the today, the Nuget release of NHibernate Validator is 1.3.1.4000 and says it has a dependency >= NHibernate 3.1.0.4000, which implies it should work with latest NHib 3.2.
But NHib 3.2 now has its own ProxyFactory, so running the two gets the following error:
System.TypeLoadException : Could not load type 'NHibernate.Bytecode.ProxyFactoryFactoryNotConfiguredException' from assembly 'NHibernate, Version=3.2.0.2001, Culture=neutral, PublicKeyToken=aa95f207798dfdb4'
I do not really need anything in NHib 3.2 now, although my preference would be to make the two work together.
Alternatively, I suppose I could drop down to NHib 3.1, but my solution has 16 projects, which where Nuget comes in. This post suggests how to get and install an older package release, but NHib 3.1 doesn't seem to be available stand alone from Nuget.
Installing Validator alone using Nuget will install the NHib 3.1 as a dependency. I have some projects that don't use Validator but do use NHib alone, and I guess I could install Validator just to get the correct dependency but that isn't a very satisfying solution.
Has anyone got the latest NHib (3.2) working with the latest NHib Validator? Suggestions?
Cheers,
Berryl
If you feel OK about using NHib 3.1 you can first add the Validator + its dependency on NHib 3.1 to the projects that require validation. Afterwards, referencing the NHib package in other projects can be done at the solution level (introduced in NuGet 1.4)

Install NHibernate 3.2 with NuGet

I'm new to NHibernate and have been trying to get up and running with it, Fluent NHibernate and NHProf using NuGet. After reading this article (http://gurustop.net/blog/2011/03/13/nhibernate-3-1-0-on-nuget-important-details) it seems that v3.1 shouldn't be directly installed, however, there appears no such warning for v3.2.
After successfully installing NHibernate 3.2 and NHProf using NuGet, I'm unable to install Fluent NHibernate as it says it's "Already referencing a newer version of NHibernate".
Also, when I run my app I get the following error "Could not load file or assembly 'NHibernate.ByteCode.Castle' or one of its dependencies". The following link (Could not load file or assembly in NHibernate) suggests installing a number of additional assemblies, which is what I was hoping to avoid by using NuGet in the first place.
At this point would it just be easier to follow the steps on NHForge to get things up and running as the packages on NuGet don't appear to be compatible?
NHibernate 3.2 comes with its own proxy factory. If you're using a config file, you just need to remove the proxyfactory configuration property.
I believe the version of Fluent NHibernate that you're using defaults to use NHibernate.ByteCode.Castle. In that case, you would need to override that setting with the built in NHibernate 3.2 proxy factory:
.ProxyFactoryFactory("NHibernate.Bytecode.DefaultProxyFactoryFactory, NHibernate")
Each version of Fluent NHibernate uses an exact version of NHibernate (included in the Fluent NHibernate package)
You should remove the NHibernate package and add only Fluent NHibernate
If you use the Nuget Package Manager Console instead of the GUI to get the package (Install-Package FluentNHibernate) you will get version 1.3.0.717 which is compatible with NHibernate 3.2
I tried and is working fine for me. I answered this already on this link: which version of fluent nhibernate is compatible with nhibernate 3.2
I'm using this consctruction in config file to make FluentNhibernate work with NHibernate 3.2
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.2.0.1001" newVersion="3.2.0.1001" />
</dependentAssembly>
</assemblyBinding>
</runtime>
NHibernate 3.2 comes with its own mapping configuration (Conform). FluentNHibernate only works with NHibernate 3.1 as a result of this, you can't use 3.2 (I had the same problem). So you'll have to manually download 3.1 and reference that unless NuGet allows you to use 3.1 directly.
Your other option is to remove all references to 3.2 and then install FluentNHibernate from NuGet, then the dependency resolver will kick in and automatically include NHibernate 3.1 for you.

Fluent NHibernate 1.1 and castle.core 2.5.0.x together issue

I'm using the latest stable build of Fluent NHibernate ver 1.1. Now in the application I'm also using castle.core for dependency injection. Now the problem is using them together. In Visual Studio castle.core says ver. 2.5.1.0 but in Windows Explorer "details" for the same DLL file it says 2.5.1.2121. I have tried both numbers in assembly binding in the web.config, to switch away from ver. 1.1.0.0 which the Fluent NHibernate castle.core references, but not with much luck.
Any suggestions to solve this issue? I do not want to build any of the assemblies myself.
The only solution I came across with this was to get the nhibernate.bytecode.castle source and build it against the latest source for castle.core - alternatively you could use a nhibernate.bytecode.linfu instead.
I rebuilt Fluent NHibernate against the latest Castle Project core and Fluent NHibernate beta2. Now it works.
I just found the solution. I used the MVC contrib project and this was the source to the problem, the Windsor controller factory. I wrote my own and removed the reference, only a few lines of code, problem solved.