Could not load type Foo from assembly NHibernate
by Jason, 03.30.06 at 5:00 am :: .NET :: permalink :: rss
This error indicates that the class could not be found when NHibernate is initializing. The key here is “from assembly NHibernate” The reason I was getting this error is because I didn’t realize that you have to specify not only the name of the class (including the namespace prefix), but also the assembly name after the class. I would have thought that NHibernate would have known the assembly name since I was giving it the full namespace, but apparently this is not the case.
For example:
[code:1:441355f572]
<class name=”myassembly.model.Foo” table=”foo”>
[/code:1:441355f572]
This is not enough information. You must also specify the assembly name, or else NHibernate uses the default assembly name of “NHibernate” It should really look like this:
[code:1:441355f572]
<class name=”myassembly.model.Foo,myassembly” table=”foo”>
[/code:1:441355f572]
myassembly would typically being the name of your .NET project. In this case, all objects are being organized in the namespace myassembly.model.
this also applies when mapping relationships:
[code:1:441355f572]
<many-to-one name=”child” column=”child_id” class=”myassembly.model.Child” not-null=”true”/>
[/code:1:441355f572]
should be:
[code:1:441355f572]
<many-to-one name=”child” column=”child_id” class=”myassembly.model.Child, myassembly” not-null=”true”/>
[/code:1:441355f572]
No comments at the moment.
Add a comment