-->
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.  [ 5 posts ] 
Author Message
 Post subject: newbie lost again
PostPosted: Thu May 25, 2006 10:13 am 
Beginner
Beginner

Joined: Mon May 22, 2006 12:12 am
Posts: 23
Hi,

Earlier I've hit the problem on :

"Could not load type 'RHU.LicenseeCandidate, NHibernate, Version=1.0.2.0, Culture=neutral, PublicKeyToken=154fdcb44c4484fc', check that type and assembly names are correct"


With some fellows' help here earlier on, I've once succeeded (but after improving the program further, I hit problem on this again without knowing why the problem comes back again).

My procedures:
1) in Visual C# Express, I created a Class project

- I've a C# class LicenseeCandidate.cs file
- I've the mapping LicenseeCandidate.hbm.xml file . In the Build box, I set this to Embedded Resoure.
- The project assembly is named RHU.RAIS (my LicenseeCandidate.cs class use the namespace RHU.RAIS as well. but I think no conflict, right?)

- after compiled, RHU.RAIS.dll is generated


Part of the xml file:
"<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="RHU.RAIS.LicenseeCandidate, RHU.RAIS" table="LicenseeCandidate">"

2) in Visual Studio Web Developer Express, I included RHU.RASI.dll and other necessary files as REFERENCE.

I was testing the SchemaExport function. So, I've these lines

Configuration cfg = new Configuration();
cfg.Configure();
cfg.AddXMLFile(System.Web.HttpContext.Current.Server.MapPath("~/App_Code/LicenseeCandidate.hbm.xml"));
SchemaExport se = New SchemaExport(cfg);
se.Create(true, true);

The above is fine and good feelings that I see the table created in database successfully. However, if I were not using the AddXMLFile to point to path, I hit the above-mentioned error when using cfg.AddAssembly("RHU.RAIS");
(or if I use cfg.AddClass(typeof(LicenseeCandidate)) which say can't find the LicenseeCandidate.hbm.xml file (which I said I've embedded as resource)

I've tested by creating an instance of LicenseeCandidate. I write out the class's GetType().FullName and it displays correctly that it is RHU.RAIS.Licensee.Candidate. The Assembly name is correct.

What's wrong on loading the Assembly?

My hiberante.cfg.xml file:

<?xml version="1.0" encoding="utf-8" ?>
<nhibernate xmlns="urn:nhibernate-configuration-2.0" >
<session-factory name="RHU.RAIS">
<!-- properties -->
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="connection.connection_string">Server=localhost;initial catalog=RAIS;User Id=dba;Password=</property>
<property name="show_sql">false</property>
<property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
<property name="use_outer_join">true</property>
<!--
these are different than the values in app.config so I can verify these
are being picked up
-->
<property name="command_timeout">444</property>
<property name="query.substitutions">true 1, false 0, yes 1, no 0</property>
<!-- mapping files -->
<!-- are now optional -->
/>
<!-- -->
</session-factory>

</nhibernate>





Your advice much much appreciated TWICE MORE. Thanks!
jL

NHibernate version 1.02

MS SQL Server 2005 Express


Top
 Profile  
 
 Post subject: Re: newbie lost again
PostPosted: Thu May 25, 2006 11:06 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
fly2moon2 wrote:
cfg.AddXMLFile(System.Web.HttpContext.Current.Server.MapPath("~/App_Code/LicenseeCandidate.hbm.xml"));


Well, as You did embbed the hbm as resource, You probly want to call
cfg.AddAssemly() instead of AddXmlFile. And the "~/App_Code/LicenseeCandidate.hbm.xml" file probly contains out-of-date data?

Gert

_________________
If a reply helps You, rate it!


Top
 Profile  
 
 Post subject: clarify
PostPosted: Thu May 25, 2006 11:41 am 
Beginner
Beginner

Joined: Mon May 22, 2006 12:12 am
Posts: 23
Hi,

Thanks for your reply.

I didn't describe well: I meant I don't have problem using the AddXMLFile method. But if I use AddAssembly method, I hit problem...


Top
 Profile  
 
 Post subject: Re: clarify
PostPosted: Thu May 25, 2006 11:59 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
fly2moon2 wrote:
I didn't describe well: I meant I don't have problem using the AddXMLFile method. But if I use AddAssembly method, I hit problem...


Sorry, my bad....

In this case, can You verify that the Bin directory of web project copntains correct version of RHU.RAIS.dll file.

Another thing to try: Rebuild the RHU.RAIS.dll to be sure that the correct version of hbm file resource is included..

Gert

_________________
If a reply helps You, rate it!


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 26, 2006 3:41 am 
Newbie

Joined: Wed May 24, 2006 5:06 am
Posts: 3
I don't know if you have solved the problem, but by the way you adviced me, my project begins to run. So, currently in my case I don't use neither AddXMLFile nor AddAssemly. Instead of that, I write:
Code:
cfg.AddAssembly(System.Configuration.ConfigurationManager.AppSettings["HBM_ASSEMBLY"]);


where HBM_ASSEMBLY is a key in the web.config like this:
Code:
<add key="HBM_ASSEMBLY" value="NHibernateSample.Core"/>


All I use comes from the article at http://www.codeproject.com/aspnet/NHibernateBestPractices.asp[/url]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.