Unity3D + NHibernate,加载崩溃"Unity 3.5 .net full Base Class Libraries"
Unity3D + NHibernate, crash loading "Unity 3.5 .net full Base Class Libraries"
我正在尝试将 Unity3d 和 NHibernate 结合起来。经过大量魔法后,它在编辑器中工作,但在 Windows 独立 .exe.
中崩溃
我拥有的主要数据访问库:
MySql.Data.dll
I18N.dll
I18N.West.dll
System.Data.dll (2.0.5, for Unity)
NHibernate.dll (3.4.0)
win应用程序启动时的崩溃是:
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
既然无法加载System.Data.Common.DbProviderFactories,我认为是无法获取System.Data。同时我的 System.Data 100% 加载清楚了,因为还有另一个验证码可以直接与 DB 完美配合,w/o 涉及 NHibernate。
难道是因为 NHibernate 是用 System.Data 从 .Net Framework visual studio 配置文件构建的,而 Unity 项目使用 2.0.5 版本?
我尝试用 System.Data 从 "Unity 3.5 .net full Base Class Libraries" 构建 NHibernate。它已成功构建,但当我将 System.Data.dll 放入插件时,Unity 也会崩溃:
InvalidProgramException: Invalid IL code in System.Data.Common.DbConnectionStringBuilder:Remove (string): IL_0000: ret
奇怪,Unity 不是应该从 c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v3.5\Profile\Unity Full v3.[=44 读取库吗=].Data.dll?
同时,我无法使用 c:\Program Files (x86)\Unity\Editor\Data\Mono\lib\mono\unity\System.Data.dll 构建 NHibernate。默认情况下,它从 GAC 加载 v2.0.0。当我尝试在 .csproj 中显式写入 2.0.5 版本时,它失败了:
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
我很绝望 - 我应该如何构建 NHibernate 以及使用哪些库使其在 Unity 中工作?
希望,有人有答案。
提前致谢!
尤拉
好吧,经过一周的定期尝试,我终于让它工作了:
- 为 .Net 3.5 构建 NHibernate(不是 "Unity profile",只是普通的 3.5)
- 将 GAC 中的 3.5 System.Data.dll 放入 Unity 中的 "plugins" 文件夹
就是这样。
我仍然想知道为什么 Unity 不能接受来自“"Unity 3.5 .net full Base Class Libraries" .Net 配置文件的库,但至少它不会再阻止我了。
我正在尝试将 Unity3d 和 NHibernate 结合起来。经过大量魔法后,它在编辑器中工作,但在 Windows 独立 .exe.
中崩溃我拥有的主要数据访问库:
MySql.Data.dll
I18N.dll
I18N.West.dll
System.Data.dll (2.0.5, for Unity)
NHibernate.dll (3.4.0)
win应用程序启动时的崩溃是:
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
既然无法加载System.Data.Common.DbProviderFactories,我认为是无法获取System.Data。同时我的 System.Data 100% 加载清楚了,因为还有另一个验证码可以直接与 DB 完美配合,w/o 涉及 NHibernate。
难道是因为 NHibernate 是用 System.Data 从 .Net Framework visual studio 配置文件构建的,而 Unity 项目使用 2.0.5 版本?
我尝试用 System.Data 从 "Unity 3.5 .net full Base Class Libraries" 构建 NHibernate。它已成功构建,但当我将 System.Data.dll 放入插件时,Unity 也会崩溃:
InvalidProgramException: Invalid IL code in System.Data.Common.DbConnectionStringBuilder:Remove (string): IL_0000: ret
奇怪,Unity 不是应该从 c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v3.5\Profile\Unity Full v3.[=44 读取库吗=].Data.dll?
同时,我无法使用 c:\Program Files (x86)\Unity\Editor\Data\Mono\lib\mono\unity\System.Data.dll 构建 NHibernate。默认情况下,它从 GAC 加载 v2.0.0。当我尝试在 .csproj 中显式写入 2.0.5 版本时,它失败了:
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
我很绝望 - 我应该如何构建 NHibernate 以及使用哪些库使其在 Unity 中工作?
希望,有人有答案。 提前致谢! 尤拉
好吧,经过一周的定期尝试,我终于让它工作了:
- 为 .Net 3.5 构建 NHibernate(不是 "Unity profile",只是普通的 3.5)
- 将 GAC 中的 3.5 System.Data.dll 放入 Unity 中的 "plugins" 文件夹
就是这样。
我仍然想知道为什么 Unity 不能接受来自“"Unity 3.5 .net full Base Class Libraries" .Net 配置文件的库,但至少它不会再阻止我了。