Note that there are some explanatory texts on larger screens.

plurals
  1. PONHibernate.MappingException: No persister for: NHibernateExperiment.Player - i can't find the solution
    text
    copied!<p>I try to make a project with the NHibernate ORM, and at one moment when i thought that all I finished , it gives me an <strong>NHibernate.MappingException: No persister for</strong> exception I read that the problem could be that i didn't added the assembly in config file, but I did this, and also it is not fixed...</p> <p>If someone has a litle time, help me please to fix the problem.</p> <p>here is <strong>the code I call</strong> to add a new Player object</p> <pre><code>private void btnInsert_Click(object sender, EventArgs e) { Player playerData = new Player(); SetPlayerInfo(playerData); using (ISession session = SessionFactory.OpenSession) { using (ITransaction transaction = session.BeginTransaction()) { try { session.Save(playerData); // here it spits transaction.Commit(); GetPlayerInfo(); } catch (Exception ex) { transaction.Rollback(); throw ex; } } } } private void GetPlayerInfo() { using (ISession session = SessionFactory.OpenSession) { IQuery query = session.CreateQuery("FROM Player"); IList&lt;Player&gt; pInfos = query.List&lt;Player&gt;(); dgvDisplay.DataSource = pInfos; } } private void SetPlayerInfo(Player playerData) { playerData.PlayerName = tbxName.Text; playerData.PlayerAge = Convert.ToInt32(tbxAge.Text); playerData.DOJ = Convert.ToDateTime(dtpDOJ.Text); playerData.BelongsTo = cmbBelongsTo.SelectedItem.ToString(); } </code></pre> <p>here is the mapping <strong>Player.hbm.xml</strong> code</p> <pre><code>&lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true"&gt; &lt;class name="NHibernateExperiment.Player, NHibernateExperiment" lazy="true"&gt; &lt;id name="PlayerId"&gt; &lt;generator class="native"/&gt; &lt;/id&gt; &lt;property name="PlayerName" column ="PlayerName"/&gt; &lt;property name="PlayerAge" column ="PlayerAge"/&gt; &lt;property name="DOJ" column="DOJ"/&gt; &lt;property name="BelongsTo" column="BelongsTo"/&gt; &lt;/class&gt; &lt;/hibernate-mapping&gt; </code></pre> <p>here is the <strong>App.config</strong> code</p> <pre><code> &lt;configuration&gt; &lt;configSections&gt; &lt;section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" /&gt; &lt;/configSections&gt; &lt;hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"&gt; &lt;session-factory&gt; &lt;property name="connection.provider"&gt;NHibernate.Connection.DriverConnectionProvider&lt;/property&gt; &lt;property name="connection.driver_class"&gt;NHibernate.Driver.SqlClientDriver&lt;/property&gt; &lt;property name="connection.connection_string"&gt;Server=GRITCAN;database=testDB;Integrated Security=SSPI;&lt;/property&gt; &lt;property name="dialect"&gt;NHibernate.Dialect.MsSql2008Dialect&lt;/property&gt; &lt;property name="show_sql"&gt;true&lt;/property&gt; &lt;property name='proxyfactory.factory_class'&gt;NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu&lt;/property&gt; &lt;/session-factory&gt; &lt;/hibernate-configuration&gt; &lt;/configuration&gt; </code></pre> <p>here is the <strong>StackTrace</strong></p> <p>at NHibernateExperiment.Form1.btnInsert_Click(Object sender, EventArgs e) in E:\projects\tests\NHibernate\NHibernateExperiment\NHibernateExperiment\Form1.cs:line 72 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message&amp; m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message&amp; m) at System.Windows.Forms.ButtonBase.WndProc(Message&amp; m) at System.Windows.Forms.Button.WndProc(Message&amp; m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp; msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at NHibernateExperiment.Program.Main() in E:\projects\tests\NHibernate\NHibernateExperiment\NHibernateExperiment\Program.cs:line 16 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()</p> <p>I've added the following 2 references to the project <strong>NHibernate.dll</strong> and <strong>NHibernate.ByteCode.LinFu.dll</strong></p> <p><strong>Thanks a lot for your help!</strong></p> <hr> <p>Thank You BOYS. The <strong>Build Action</strong> for <strong>.hbm.xml</strong> file was <strong>Content</strong>. As you suggested me I changed it to <strong>Embedded Resource</strong> and all works fine:) </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