首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法加载类型Nhibernate.Dialect.MsSql2012Dialect。可能的原因:未指定程序集名称

无法加载类型Nhibernate.Dialect.MsSql2012Dialect。可能的原因:未指定程序集名称
EN

Stack Overflow用户
提问于 2016-07-10 00:34:59
回答 0查看 2.5K关注 0票数 0

这是我在运行application.Could not load type nhibernat.Mssql2012时遇到的错误。我使用的是sqlserver2012,visual studio 2015

强文本Web配置:

代码语言:javascript
复制
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler,Nhibernate"/>
  </configSections>
  <connectionStrings>
    <add name="MainDatabase" connectionString="Data Source=SARVESH\SQLEXPRESS;Database=SimpleBlog;Integrated Security=True"/>
  </connectionStrings>
  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
      <session-factory>

      <property name="dialect">Nhibernate.Dialect.MsSql2012Dialect</property>  
        <property name="connection.provider">Nhibernate.Connection.DriverConnectionProvider</property>
        <property name="connection.driver_class">Nhibernate.Driver.SqlClientDriver</property>
        <property name="connection.connection_string_name">MainDatabase</property>



      </session-factory>


    </hibernate-configuration>

  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>

Database.cs

代码语言:javascript
复制
namespace simpleblog
{
    public static class Database
    {
        private const string SESSION_KEY = "simpleblog.database.sessionkey";
        private static ISessionFactory _sessionFactory;
        public static ISession session
        {
            get { return (ISession)HttpContext.Current.Items[SESSION_KEY]; }


        }
        public static void Configure()
        {
            var config = new Configuration();
            //configure the connection strings
            config.Configure();
            //add our mappings
            var mapper = new ModelMapper();
            mapper.AddMapping<UserMap>();
            config.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());
            //create session factory
            _sessionFactory = config.BuildSessionFactory();



        }

        public static void OpenSession()
        {
            HttpContext.Current.Items[SESSION_KEY]= _sessionFactory.OpenSession();
        }

        public static void CloseSession()
        {
            var session = HttpContext.Current.Items[SESSION_KEY] as ISession;
            if (session != null)
                session.Close();

            HttpContext.Current.Items.Remove(SESSION_KEY);

        }
    }
}
EN

回答

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

https://stackoverflow.com/questions/38283947

复制
相关文章

相似问题

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