运行 Fluent NHibernate 项目 Visual Studio 2015 Mac 时出现错误 500
Error 500 while running a Fluent NHibernate Project with Visual Studio 2015 for Mac
所以,我正在尝试 运行 ASP.NET MVC 5 与 NHibernate 和 FluentNHibernate 目标 SQL 服务器 2012 与 Visual Studio 2015 Mac和 XSP 网络服务器,它会失败,但出现以下异常。我正在使用 .NET Framework 4.5 并且程序包已更新到最新版本。
System.ArgumentNullException
Value cannot be null.
Parameter name: type
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): System.Core.
Exception stack trace:
at System.Dynamic.Utils.ContractUtils.RequiresNotNull (System.Object value, System.String paramName) [0x00003] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/external/corefx/src/Common/src/System/Dynamic/Utils/ContractUtils.cs:67
at System.Linq.Expressions.Expression.Convert (System.Linq.Expressions.Expression expression, System.Type type, System.Reflection.MethodInfo method) [0x0000b] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/UnaryExpression.cs:780
at System.Linq.Expressions.Expression.Convert (System.Linq.Expressions.Expression expression, System.Type type) [0x00000] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/UnaryExpression.cs:763
at NHibernate.Util.DelegateHelper.BuildPropertySetter[T] (System.Type type, System.String propertyName) [0x00015] in <1c5d1dfd6b734554b068885679d8b49d>:0
at NHibernate.AdoNet.SqlClientSqlCommandSet..cctor () [0x00019] in <1c5d1dfd6b734554b068885679d8b49d>:0
也许这是 NHibernate 或 FluentNHibernate 的错误?
我想我找到了解决办法。因为bug什么的,我们需要配置数据库的batch size为0来避免这个异常:
return Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2012.ConnectionString(
x => x.FromConnectionStringWithKey("ConexaoBanco")).ShowSql())
.Mappings(m =>
m.FluentMappings.AddFromAssemblyOf<HomeController>())
.ExposeConfiguration(cfg => cfg.SetProperty("adonet.batch_size", "0"))
.BuildSessionFactory();
我应该适当感谢 sta-blockhead 的解决方案:http://sta-blockhead.blogspot.com.br/2009/06/systemdatasqlclientsqlcommandset.html
所以,我正在尝试 运行 ASP.NET MVC 5 与 NHibernate 和 FluentNHibernate 目标 SQL 服务器 2012 与 Visual Studio 2015 Mac和 XSP 网络服务器,它会失败,但出现以下异常。我正在使用 .NET Framework 4.5 并且程序包已更新到最新版本。
System.ArgumentNullException
Value cannot be null.
Parameter name: type
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): System.Core.
Exception stack trace:
at System.Dynamic.Utils.ContractUtils.RequiresNotNull (System.Object value, System.String paramName) [0x00003] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/external/corefx/src/Common/src/System/Dynamic/Utils/ContractUtils.cs:67
at System.Linq.Expressions.Expression.Convert (System.Linq.Expressions.Expression expression, System.Type type, System.Reflection.MethodInfo method) [0x0000b] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/UnaryExpression.cs:780
at System.Linq.Expressions.Expression.Convert (System.Linq.Expressions.Expression expression, System.Type type) [0x00000] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/UnaryExpression.cs:763
at NHibernate.Util.DelegateHelper.BuildPropertySetter[T] (System.Type type, System.String propertyName) [0x00015] in <1c5d1dfd6b734554b068885679d8b49d>:0
at NHibernate.AdoNet.SqlClientSqlCommandSet..cctor () [0x00019] in <1c5d1dfd6b734554b068885679d8b49d>:0
也许这是 NHibernate 或 FluentNHibernate 的错误?
我想我找到了解决办法。因为bug什么的,我们需要配置数据库的batch size为0来避免这个异常:
return Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2012.ConnectionString(
x => x.FromConnectionStringWithKey("ConexaoBanco")).ShowSql())
.Mappings(m =>
m.FluentMappings.AddFromAssemblyOf<HomeController>())
.ExposeConfiguration(cfg => cfg.SetProperty("adonet.batch_size", "0"))
.BuildSessionFactory();
我应该适当感谢 sta-blockhead 的解决方案:http://sta-blockhead.blogspot.com.br/2009/06/systemdatasqlclientsqlcommandset.html