FluentNhibernate TypeLoadException [英] FluentNhibernate TypeLoadException

查看:185
本文介绍了FluentNhibernate TypeLoadException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图建立使用FluentNhibernate样本MVC3项目,我得到一个typeloadexception当我尝试创建一个SessionFactory。

I'm trying to build a sample MVC3 project using FluentNhibernate, and I'm getting a typeloadexception when I try to create a sessionFactory.

的SessionFactory

//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

我在别处使用这个确切的code在没有问题的过去,我不知道可能是什么问题。难道我做错了吗?

I've used this exact code elsewhere in the past with no problem, and I don't know what could be the issue. Am I doing something wrong here?

推荐答案

据我了解,如果你在MonoDevelop中的任何错误,只需删除您的项目,把你的笔记本电脑窗外,然后你有一个明确的开盘跳出它背后。 :P

I have learned that if you have any errors in Monodevelop, simply delete your project, throw your laptop out the window, and then you have a clear opening to jump out of it behind it. :P

老实说,我不得不删除该项目,使用备份并做我第一次参加的具体步骤和它的工作。所以,我很抱歉,我唯一的建议是,以节省许多备份沿途。基本上,如果您在建立它在你的输出任何错误,但没有。只需把它删掉,然后再试一次。一旦编译器是混淆它会走神的行为来解决它。

Honestly, I had to delete the project, use a backup and do the exact steps I first took and it worked. So I'm sorry my only advice is to save many backups along the way. Basically if you have any errors in your output, but none when you build it. Just delete it and try again. Once the compiler is confused it would take an act of God to fix it.

这篇关于FluentNhibernate TypeLoadException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆