簡體   English   中英

FluentNhibernate TypeLoadException

[英]FluentNhibernate TypeLoadException

我正在嘗試使用FluentNhibernate構建示例MVC3項目,並且在嘗試創建sessionFactory時遇到typeloadexception。

會話工廠

//using System;
//using NHibernate;
//using NHibernate.Cfg;
//using FluentNHibernate.Cfg;
//using FluentNHibernate.Cfg.Db;
//using System.Collections.Generic;
//using System.Linq;
//using System.Web;
//using System.Web.Mvc;    

public class SessionProvider
{
    public SessionProvider ()
    {
    }
    public static ISessionFactory BuildFactory()
{
    return Fluently.Configure()//Explosion here
          .Database(MySQLConfiguration.Standard.ConnectionString(
          c => c.FromConnectionStringWithKey("DashboardModels")
      ))
    .Mappings(m => m.FluentMappings.AddFromAssemblyOf<Accounts>())
    .BuildSessionFactory();

}

}

Global.Asax

public class MvcApplication : System.Web.HttpApplication
{

    public static ISessionFactory SessionFactory =
             SessionProvider.BuildFactory();

    public static void RegisterGlobalFilters(GlobalFilterCollection filters)
    {
        filters.Add(new HandleErrorAttribute());
    }

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );

    }

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

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

例外

System.TypeInitializationException: An exception was thrown by the type initializer for 
System.Web.Configuration.WebConfigurationManager ---> System.Exception: Method not found: 'System.Configuration.ConfigurationManager.get_ConfigurationFactory'.
  --- End of inner exception stack trace ---
  at (wrapper xdomain-invoke) System.AppDomain:DoCallBack (System.CrossAppDomainDelegate)
  at (wrapper remoting-invoke-with-check) System.AppDomain:DoCallBack (System.CrossAppDomainDelegate)
  at System.Web.Hosting.ApplicationHost.CreateApplicationHost (System.Type hostType, System.String virtualDir, System.String physicalDir) [0x00000] in <filename unknown>:0
  at Mono.WebServer.VPathToHost.CreateHost (Mono.WebServer.ApplicationServer server, Mono.WebServer.WebSource webSource) [0x00000] in <filename unknown>:0
 at Mono.WebServer.XSP.Server.RealMain (System.String[] args, Boolean root, IApplicationHost ext_apphost, Boolean quiet) [0x00000] in <filename unknown>:0
 at Mono.WebServer.XSP.Server.Main (System.String[] args) [0x00000] in <filename unknown>:0

過去,我在其他地方使用過此確切的代碼沒有問題,而且我不知道可能是什么問題。 我在這里做錯什么了嗎?

我們了解到,如果您在Monodevelop中有任何錯誤,只需刪除項目,將筆記本電腦丟到窗外,然后您就會有一個明顯的開口可以跳出它。 :P

老實說,我必須刪除項目,使用備份,並按照我最初采取的確切步驟進行操作。 因此,很抱歉,我唯一的建議是一路上保存許多備份。 基本上,如果您的輸出中有任何錯誤,但是在構建時則沒有。 請刪除它,然后重試。 一旦編譯器感到困惑,它將需要神的行為來修復它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM