0

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();

}

}

グローバルアサックス

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

過去にこの正確なコードを他の場所で問題なく使用しましたが、何が問題なのかわかりません。ここで何か間違ったことをしていますか?

4

1 に答える 1

1

Monodevelopでエラーが発生した場合は、プロジェクトを削除し、ラップトップをウィンドウから外すだけで、プロジェクトの背後から飛び出すための明確な開口部があることを学びました。:P

正直なところ、私はプロジェクトを削除し、バックアップを使用して、最初に行った正確な手順を実行する必要があり、それは機能しました。申し訳ありませんが、私の唯一のアドバイスは、途中で多くのバックアップを保存することです。基本的に、出力にエラーがある場合ですが、ビルド時にエラーはありません。削除して再試行してください。コンパイラが混乱すると、それを修正するには神の行動が必要になります。

于 2013-02-13T21:33:22.130 に答える