Unity3D + NHibernate, crash load "Unity 3.5.net full Base Class Libraries"

I am trying to marry Unity3d and NHibernate. After a lot of magic it works in editor but crashes in standalone .exe Windows.

Basic data access libraries I have:

MySql.Data.dll
I18N.dll
I18N.West.dll
System.Data.dll (2.0.5, for Unity)
NHibernate.dll (3.4.0)

      

Failure to start the application to run:

TypeLoadException: Could not load type 'System.Data.Common.DbProviderFactories' from assembly 'NHibernate'.
  at NHibernate.Driver.MySqlDataDriver..ctor () [0x00000] in d:\Downloads\nh\NHibernate-3.4.0.GA-src\src\NHibernate\Driver\MySqlDataDriver.cs:27 

.........  omitted System.Reflection chain .......


  at NHibernate.Connection.ConnectionProvider.ConfigureDriver (IDictionary`2 settings) [0x00020] in d:\Downloads\nh\NHibernate-3.4.0.GA-src\src\NHibernate\Connection\ConnectionProvider.cs:107 
Rethrow as HibernateException: Could not create the driver from NHibernate.Driver.MySqlDataDriver, NHibernate, Version=3.4.0.0, Culture=neutral, PublicKeyToken=null.
  at NHibernate.Connection.ConnectionProvider.ConfigureDriver (IDictionary`2 settings) [0x00052] in d:\Downloads\nh\NHibernate-3.4.0.GA-src\src\NHibernate\Connection\ConnectionProvider.cs:113 

  at NHibernate.Connection.ConnectionProvider.Configure (IDictionary`2 settings) [0x0004f] in d:\Downloads\nh\NHibernate-3.4.0.GA-src\src\NHibernate\Connection\ConnectionProvider.cs:64 

  at NHibernate.Connection.ConnectionProviderFactory.NewConnectionProvider (IDictionary`2 settings) [0x000bd] in d:\Downloads\nh\NHibernate-3.4.0.GA-src\src\NHibernate\Connection\ConnectionProviderFactory.cs:50 

      

Since it cannot load System.Data.Common.DbProviderFactories, I think it cannot get System.Data. At the same time, my System.Data is 100% loaded explicitly because there is another authentication code that works fine with the DB directly, without NHibernate involved.

Could it be because NHibernate is built with System.Data from the .NET Framework visual studio profiles, while the Unity project is using version 2.0.5?

I was trying to create NHibernate with System.Data from "Unity 3.5.net Complete Base Classes". It was successfully created, but Unity also crashes when I add this System.Data.dll file to the plugins:

InvalidProgramException: Invalid IL code in System.Data.Common.DbConnectionStringBuilder:Remove (string): IL_0000: ret    

      

The strange thing is that Unity shouldn't read libs from c: \ Program Files (x86) \ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v3.5 \ Profile \ Unity Full v3.5 \ System.Data.dll

At the same time, I cannot create NHibernate with c: \ Program Files (x86) \ Unity \ Editor \ Data \ Mono \ lib \ mono \ unity \ System.Data.dll. By default it downloads v2.0.0 from the GAC. When I try to explicitly write version 2.0.5 in .csproj it fails:

Warning 2   The primary reference "System.Data, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 processorArchitecture=x86" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Transactions, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "2.0.5.0" than the version "2.0.0.0" in the current target framework.   NHibernate

      

I'm desperate - how should I build NHibernate and what libraries should I use to make it work in Unity?

Hope someone has an answer. Thank you in advance! Yura

+3


source to share


1 answer


Well, after a week of intermittent attempts I finally did this:

  • Build NHibernate for .Net 3.5 (NOT "Unity Profile", just regular 3.5)
  • Place 3.5 System.Data.dll from the GAC into the "plugins" folder in Unity


What is it.

I'm still wondering why Unity can't accept libs from the "Unity 3.5.net full Base Class Libraries" .Net profile, but at least that doesn't block me anymore.

+1


source







All Articles