-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: Could not load type form assembly ..........
PostPosted: Fri Dec 16, 2005 8:16 am 
Newbie

Joined: Fri Dec 16, 2005 8:02 am
Posts: 1
Hi ,

I am new to NHibernate. I am trying to do one sample on that.
I am getting one exception and i could not resolve this one.

Assembly Name : HibernateSample
Class Name : Employee

Employee.hbm.xml
-----------------------

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-access="property">
<class name="NHibernate.HibernateSample.Employee, HibernateSample" table="employee">
<id name="Id" column="emp_id">
<generator class="assigned" />
</id>
<property name="FirstName" column="fname" type="String"/>
<property name="LastName" column="lname" type="String"/>
<property name="JobId" column="job_id" type="Integer"/>
<property name="Hiredate" column="hire_date" type="DateTime"/>

</class>
</hibernate-mapping>

I have added the assembly like this

nhConfig.AddAssembly("HibernateSample")

I am getting exception after above line

Could not load type NHibernate.HibernateSample.Employee from assembly HibernateSample.


Can anyone help me please ...........

Thanks,
Natraj


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 16, 2005 11:17 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
This is a very common issue for newbies.

Make sure that your hbm.xml file is an "Embedded Resource" in your VS.NET project...

If you still can't solve that, do some search on this forum; there are load of topics about it with all possible solutions (you may use the keywords: "could not load type" or "MappingException")

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 5:23 am 
Quote:
This is a very common issue for newbies.

Make sure that your hbm.xml file is an "Embedded Resource" in your VS.NET project...


How to do that in Visual Studio 2005? I can't choose the kind of reference... is there a workaround for VS 2005?


Top
  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 5:40 am 
Senior
Senior

Joined: Wed Jun 15, 2005 4:17 am
Posts: 156
SOL-Invictus wrote:
How to do that in Visual Studio 2005? I can't choose the kind of reference... is there a workaround for VS 2005?


Don't try to add the mapping file as a reference! Instead add the mapping to the solution (as an existing file) or create a new XML file. Click on the file name in the solution explorer. Look at the properties pane. The first property is named "Build Action". From the dropdown select "Embedded Resource". It works the same for all VS versions.

Cheers,
Radu


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 5:58 am 
radu wrote:
Don't try to add the mapping file as a reference! Instead add the mapping to the solution (as an existing file) or create a new XML file. Click on the file name in the solution explorer. Look at the properties pane. The first property is named "Build Action". From the dropdown select "Embedded Resource". It works the same for all VS versions.

Cheers,
Radu


Thats the problem, if i do as you said, klick on the file and then the properties, the first field is Misc - 'File Name', the other one is 'Full Path' - there are no other properties left...


Top
  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 9:12 am 
The problem is in connection with Visual Studio 2005 ( as here http://nhibernate.sourceforge.net/forum ... .php?t=514 post nr. 6 and 7 also describes)... there is no "Embedded Resource" to choose


Top
  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 11:20 am 
Senior
Senior

Joined: Wed Jun 15, 2005 4:17 am
Posts: 156
SOL-Invictus wrote:
Thats the problem, if i do as you said, klick on the file and then the properties, the first field is Misc - 'File Name', the other one is 'Full Path' - there are no other properties left...


That happens if you add the file to a Web Project! The new deployment model for web applications does not create a single dll for your web project anymore, but it compiles every page independently. On this model indeed there is no way to add the mapping file as an embeded resource. Instead, create all your business domain classes in a class library project as this will also help you to decouple your business tier from the UI tier. In a class library project you will be able to embed your mappings as resources.

HTH,
Radu


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 21, 2005 6:04 am 
radu wrote:
That happens if you add the file to a Web Project! The new deployment model for web applications does not create a single dll for your web project anymore, but it compiles every page independently. On this model indeed there is no way to add the mapping file as an embeded resource. Instead, create all your business domain classes in a class library project as this will also help you to decouple your business tier from the UI tier. In a class library project you will be able to embed your mappings as resources.

HTH,
Radu


Thanks for your explanation and help!

Ok, then i will try to do it with a class library...

*Newbie* Phuu! :)


Top
  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.