gpt4 book ai didi

asp.net-mvc-3 - NHibernate on Mono 运行 ASP.NET MVC 3 web 应用程序

转载 作者:行者123 更新时间:2023-11-29 12:13:30 24 4
gpt4 key购买 nike

我在 Mono(Ubuntu 服务器 13.04)上使用 NHibernate 时遇到问题

单声道版本:

Mono JIT compiler version 3.2.1 ((no/f3f789e Wed Aug 21 17:40:25 UTC 2013)
Copyright (C) 2002-2012 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen

我得到这个异常:

System.InvalidProgramException
Invalid IL code in System.Data.Common.DbProviderFactories:GetFactory (string): method body is empty.

详细信息:

Non-web exception. Exception origin (name of application or object): NHibernate.

异常堆栈跟踪:

at NHibernate.Driver.ReflectionBasedDriver..ctor (System.String providerInvariantName, System.String driverAssemblyName, System.String connectionTypeName, System.String commandTypeName) [0x00000] in <filename unknown>:0 
at NHibernate.Driver.NpgsqlDriver..ctor () [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0

我得到异常的代码如下所示:

    protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();

RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);

//NpgsqlEventLog.Level = LogLevel.Debug;
//NpgsqlEventLog.LogName = "NpgsqlTests.LogFile";

SessionFactory = Fluently.Configure().Database(FluentNHibernate.Cfg.Db.PostgreSQLConfiguration.Standard.
ConnectionString(c =>
c.Host("localhost")
.Database("newtest")
.Username("postgres")
.Password("******")
.Port(5432)
)).Mappings(m =>
m.FluentMappings.AddFromAssemblyOf<Entity>())
.ExposeConfiguration(c => c.SetProperty("current_session_context_class", "web"))
.BuildSessionFactory();
}

最佳答案

我通过删除 Web.Config 文件中不需要的引用解决了我的问题。仍然有 Entity Framework 的配置部分,即使我已经用 NuGet 删除了它。

当所有这些不需要的 dll 引用在 Web.Config 中被删除时,项目在单声道环境中正常运行,所以我在初始条目中提到的错误有点误导,因为这些问题与 NHibernate 无关。

关于asp.net-mvc-3 - NHibernate on Mono 运行 ASP.NET MVC 3 web 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18399355/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com