Note that there are some explanatory texts on larger screens.

plurals
  1. POC# Nhibernate: The 'assembly' attribute is not declared
    text
    copied!<p>I have been trying to fix my problem for a few hours now, so I think it's time to post a question here. </p> <p><strong>Problem</strong><br/> When I fire up my unit test to check my hibernate configuration is gives me an exception:</p> <blockquote> <p>An exception occurred parsing configuration :The 'assembly' attribute is not declared.</p> </blockquote> <p><strong>My code</strong><br/> hibernate.cfg.xml<br/></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" assembly="Pccleaner.Dmt"&gt; &lt;session-factory&gt; &lt;property name='proxyfactory.factory_class'&gt;NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu&lt;/property&gt; &lt;property name="connection.provider"&gt;NHibernate.Connection.DriverConnectionProvider&lt;/property&gt; &lt;property name="connection.driver_class"&gt;NHibernate.Driver.MySqlDataDriver&lt;/property&gt; &lt;property name="connection.connection_string"&gt;Database=****;Data Source=localhost;User Id=****;Password=*****&lt;/property&gt; &lt;property name="dialect"&gt;NHibernate.Dialect.MySQLDialect&lt;/property&gt; &lt;property name="show_sql"&gt;true&lt;/property&gt; &lt;mapping assembly="Pccleaner.Dmt"/&gt; &lt;/session-factory&gt; </code></pre> <p></p> <p>myunittest.cs<br/></p> <pre><code>var cfg = new Configuration().Configure(); new SchemaExport(cfg).Execute( false, true, false); </code></pre> <p><strong>What I have tried</strong><br/> I have found examples of adding manually the assembly. I prefer to set my assembly in the config file but in order to get it working I tried this code:</p> <pre><code>var cfg = new Configuration(); cfg.AddAssembly("Pccleaner.Dmt"); cfg.Configure(); new SchemaExport(cfg).Execute( false, true, false); </code></pre> <p>This code resulted in the following exception:</p> <blockquote> <p>Could not compile the mapping document: Pccleaner.Dmt.Mappings.Project.hbm.xml ----> System.InvalidOperationException : Could not find the dialect in the configuration</p> </blockquote> <p>The configuration file Project.hbm.xml is like the following:</p> <pre><code>&lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Pccleaner.Dmt" namespace="Pccleaner.Dmt"&gt; &lt;class name="Project" table="pcc_dmt_project"&gt; &lt;id name="ID" column="id"&gt; &lt;generator class="identity" /&gt; &lt;/id&gt; &lt;property name="Name" not-null="true" column="name" length="50"/&gt; &lt;property name="SvnRepository" not-null="true" column="svn_repository" /&gt; &lt;property name="SvnUserName" not-null="false" column="svn_user_name"/&gt; &lt;property name="SvnUserPassword" not-null="false" column="svn_user_password"/&gt; &lt;bag name="Revisions" cascade="all"&gt; &lt;key column="project_id"/&gt; &lt;one-to-many class="Pccleaner.Dmt.Revision"/&gt; &lt;/bag&gt; &lt;/class&gt; &lt;/hibernate-mapping&gt; </code></pre> <p>Project.cs:</p> <pre><code>namespace Pccleaner.Dmt { public class Project { public virtual int ID { get; set; } public virtual string Name { get; set; } public virtual string SvnRepository { get; set; } public virtual string SvnUserName { get; set; } public virtual string SvnUserPassword { get; set; } public virtual IList&lt;Revision&gt; Revisions { get; set; } } } </code></pre> <p>Searching on the different exceptions does not give me any clues to fix this. It was working before I removed the dupplicated hibernate config in my test project. For every hibernate config file I changed the properties to embed it as resource. The hibernate config file is copied to my bin folder of my test project.</p> <p>Im new to hibernate and the different exceptions and ways to configure hibernate cause my brain to dizzle. Can you guys help me please?</p> <p>offtopic: The create new account of this website does not work: It gives me a no page found exception.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload