Login

Username

Password





Register   Reset password

This is a read-only archive of the forum.

# jcuya 12/1/2006 9:38 AM
Hi

I'm creating my first module edit page, but I get this error:

Kan type Cuyahoga.Modules.Application.Preferences niet laden vanuit assembly Cuyahoga.Modules

Don't know what I'm doing wrong, it's exactly how the articles module works and how it is described in the module development guide.

The tables look like this:
+--------------------+   +--------------+
| vmi_preferences    |   | vmi_template |
+--------------------+   +--------------+
| vprId              |  /| vteId        |
| vprUrl             | / | vteTemplate  |
| vprTemplate        |/  +--------------+
+--------------------+

And for example, Preferences.hbm.xml:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Cuyahoga.Modules.Application.Preferences, Cuyahoga.Modules" table="vmi_preferences">
<id name="Id" column="vprId" type="Int32" unsaved-value="-1">
<generator class="native">
<param name="sequence">vmi_preferences_vprId_seq</param>
</generator>
</id>
<property name="Url" column="vprUrl" type="String" length="100" not-null="false" />
<many-to-one name="Template" class="Cuyahoga.Modules.Application.Template, Cuyahoga.Modules" column="vprTemplate" cascade="none" />
</class>
</hibernate-mapping>

And Preferences.cs:
using System;
namespace Cuyahoga.Modules.Application {

  public class Preferences {
    private int _id;
    private string _url;
    private Template _template;

    /* getters and setters */

    public Preferences() {
      this._id = -1;
    }
  }
}


And at least the code in the constructor of ApplicationModule.cs:
Preferences pref = new Preferences();
SessionFactory sf = SessionFactory.GetInstance();
sf.RegisterPersistentClass(typeof(Cuyahoga.Modules.Application.Preferences));
sf.RegisterPersistentClass(typeof(Cuyahoga.Modules.Application.Template));
base.SessionFactoryRebuilt = sf.Rebuild();

When i delete the lines with registerPersistentClass, nothing goes wrong (offcourse the code doesn't work but I get no errors)

# martijnb 12/1/2006 10:22 AM
Did you set the hbm.xml files as embedded resource in Visual Studio?
# jcuya 12/4/2006 2:23 AM
Yes I did
# mgaerber 12/4/2006 8:05 AM
Just a wild guess: I had similar issues involving a class having the same name as an existing one in Cuyahoga (Article.cs).

What happens if you rename Template to Template2 ?
# martijnb 12/5/2006 3:17 AM
Just adding to mgaerbers response: if you add the attribute auto-import="false" to the hibernate-mapping tag of your mapping file, it's possible to work with your own classes that have the same name as the Cuyahoga classes.
Only caveat here is that you have to use the fully qualified classname in hql queries.
# jcuya 12/5/2006 3:32 AM (edited 12/7/2006 3:47 AM)
You are right Martijn, changing the classnames doesn't change the situation.

Any idea how I can solve this problem?