gpt4 book ai didi

NHibernate 配置问题

转载 作者:行者123 更新时间:2023-12-04 21:56:18 24 4
gpt4 key购买 nike

我觉得发布这个很愚蠢,但我看不出这里有什么问题。我想看看热门的 Nhibernate 作品,然后我进入了网站,下载了它,并按照快速入门教程进行操作,但尝试了一些机会 - 我正在使用 MySql,它不是产品而是我项目中的用户,但无论如何。 ..

当我运行模式生成测试时出现错误,错误信息如下:

TestCase 'Uniflu.Domain.Tests.GenerateSchema_Fixture.Can_generate_schema'  failed: NHibernate.MappingException : Could not compile the mapping document:  Uniflu.Domain.Mappings.Usuario.hbm.xml  ----> NHibernate.HibernateException : Could not instantiate dialect class     NHibernate.Dialect.MySqlDialect  ----> System.TypeLoadException : Could not load type NHibernate.Dialect.MySqlDialect.Possible cause: no assembly name specified.  em NHibernate.Cfg.Configuration.LogAndThrow(Exception exception)  em NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument doc)  em NHibernate.Cfg.Configuration.ProcessMappingsQueue()  em NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream, String name)  em NHibernate.Cfg.Configuration.AddResource(String path, Assembly assembly)  em NHibernate.Cfg.Configuration.AddAssembly(Assembly assembly)  E:\Projetos\Uniflu\Uniflu\Uniflu.Domain\Tests\GenerateSchema_Fixture.cs(17,0): em Uniflu.Domain.Tests.GenerateSchema_Fixture.Can_generate_schema()  --HibernateException  em NHibernate.Dialect.Dialect.InstantiateDialect(String dialectName)  em NHibernate.Dialect.Dialect.GetDialect(IDictionary`2 props)  em NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument doc)  --TypeLoadException  em NHibernate.Util.ReflectHelper.TypeFromAssembly(AssemblyQualifiedTypeName name, Boolean throwOnError)  em NHibernate.Util.ReflectHelper.ClassForName(String name)  em NHibernate.Dialect.Dialect.InstantiateDialect(String dialectName)  0 passed, 1 failed, 0 skipped, took 5,37 seconds (NUnit 2.5).  

My hibernate.cfg.xml:

<?xml version="1.0" encoding="utf-8" ?>  
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory name="Test">
<property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.MySqlDialect</property>
<property name="connection.connection_string">Server=Athenas;Database=uniflu;Uid=alaor;Pwd=test;</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>

我的用户类别:

using System;  
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Uniflu.Domain
{
public class Usuario
{
public virtual Guid Id { get; set; }
public virtual String Nome { get; set; }
public virtual String Email { get; set; }
public virtual String Senha { get; set; }
public virtual String Dica { get; set; }
public virtual DateTime DataCriado { get; set; }
public virtual DateTime UltimoAcesso { get; set; }
public virtual Boolean Ativo { get; set; }
}
}

我的 Usuario.hbm.xml:

<?xml version="1.0" encoding="utf-8" ?>  
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Uniflu.Domain"
namespace="Uniflu.Domain">
<class name="Usuario">
<id name="Id">
<generator class="guid" />
</id>
<property name="Nome" />
<property name="Email" />
<property name="Senha" />
<property name="Dica" />
<property name="DataCriado" />
<property name="UltimoAcesso" />
<property name="Ativo" />
</class>
</hibernate-mapping>

我的解决方案名称是Uniflu,我的项目是Uniflu.Domain,是一个类库项目,目录结构是这样的:

联合流感
-> Uniflu.Domain
-> -> 属性
-> -> 引用资料
-> -> 映射
-> -> -> Usuario.hbm.xml
-> -> 测试
-> -> GenerateSchema_Fixture
-> -> hibernate.hbm.xml
-> -> Usuario.cs

Guyz 我看不出我做错了什么......我真的需要一些光!!请!!

提前致谢。

最佳答案

您在 hibernate.cfg.xml 中拼错了 MySQLDialect(注意大小写)。

始终注意异常消息和堆栈跟踪。

关于NHibernate 配置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1250140/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com