首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FluentNhibernate TypeLoadException

FluentNhibernate TypeLoadException
EN

Stack Overflow用户
提问于 2013-02-12 21:35:51
回答 1查看 359关注 0票数 0

我正在尝试使用MVC3构建一个示例FluentNhibernate项目,当我尝试创建一个sessionFactory时,我得到了一个典型的sessionFactory。

SessionFactory

代码语言:javascript
复制
//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

代码语言:javascript
复制
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);
    }
}

异常

代码语言:javascript
复制
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

我以前在其他地方使用过这个精确的代码,没有问题,我也不知道会有什么问题。我在这里做错什么了吗?

EN

回答 1

Stack Overflow用户

发布于 2013-02-13 21:33:22

我已经了解到,如果您在Monodevelop中有任何错误,只需删除您的项目,将您的笔记本电脑扔出窗口,然后您将有一个明显的空缺跳出它背后。:P

老实说,我不得不删除这个项目,使用一个备份,并执行我第一次采取的步骤,它起作用了。所以我很抱歉,我唯一的建议是在路上保存很多备份。基本上,如果您在输出中有任何错误,但是在构建它时没有错误。只要删除它,然后再试一次。一旦编译器感到困惑,就会采取上帝的行动来修复它。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14842290

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档