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: Castle.DynamicProxy library loading error...
PostPosted: Thu Oct 18, 2007 9:48 am 
Newbie

Joined: Fri Aug 18, 2006 7:30 am
Posts: 5
Hibernate version: 1.2.0 GA


Hello,

I have a trouble with Lazy initialization...
If in my mapping file I change lazy="false" to "true", I have the following error (impossible to load library Castle.DynamicProxy.dll) :
Code:
{"Impossible de charger le fichier ou l'assembly 'Castle.DynamicProxy, Version=1.1.5.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' ou une de ses dépendances. Le fichier spécifié est introuvable.":"Castle.DynamicProxy, Version=1.1.5.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc"}
    [System.IO.FileNotFoundException]: {"Impossible de charger le fichier ou l'assembly 'Castle.DynamicProxy, Version=1.1.5.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' ou une de ses dépendances. Le fichier spécifié est introuvable.":"Castle.DynamicProxy, Version=1.1.5.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc"}
    Data: {System.Collections.ListDictionaryInternal}
    HelpLink: null
    InnerException: null
    Message: "Impossible de charger le fichier ou l'assembly 'Castle.DynamicProxy, Version=1.1.5.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' ou une de ses dépendances. Le fichier spécifié est introuvable."
    Source: "NHibernate"
    StackTrace: "   à NHibernate.Proxy.CastleProxyFactory..cctor()"
    TargetSite: {Void .cctor()}


My mapping file :
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
    <class name="*****.Dao.Nhibernate.Site, *****.Dao.Nhibernate" table="SAT_ADRSIT" lazy="true">
    <id name="ID" type="String" column="NUMADR">
        <generator class="assigned"/>
    </id>
    <property name="Name" column="NOMCLI" type="String" not-null="false" />
</class>
</hibernate-mapping>


My class :
Code:
    [Serializable]
    public class Site : DomainObject<String>
    {


        private String name;

        public Site()
        {
        }

         public virtual String Name {
             get { return name; }
             set { name = value;}
         }


        public override int GetHashCode()
        {
            return ID.GetHashCode();
        }

     }


It works fine with lazy="false", and loaded values are ok...

Any ideas ?

thanks


Last edited by cyrille on Thu Oct 18, 2007 11:15 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 18, 2007 10:31 am 
Beginner
Beginner

Joined: Thu Oct 26, 2006 4:45 am
Posts: 39
I had the same problem. the only solution is to switch lazy loading in the mapping file

http://forum.hibernate.org/viewtopic.ph ... namicproxy


Top
 Profile  
 
 Post subject: Castle.DynamicProxy library loading error... Access denied
PostPosted: Thu Oct 18, 2007 3:55 pm 
Newbie

Joined: Thu Oct 18, 2007 3:16 pm
Posts: 2
Location: Netherlands
Hi,

Used example from NHibernate quickstart together with NHibernate version NHibernate-1.2.0.GA.

Looks like is working until using the

Code:
session = factory.OpenSession();
User joeCool = (User)session.Load(typeof(User), "joe_cool");


then the following exception is comming up:

Code:
Unhandled Exception: NHibernate.HibernateException: Creating a proxy instance failed ---> System.TypeLoadException: Access is denied: 'hbrnt.User'.


Debuging the whole case down into the Castle stuff it goes wrong anywhere in
Castle.DynamicProxy.Builder.CodeBuilder.AbstractEasyType.BuildType()

However setting the lazy attribute to false helps in this case.

Code:
<class name="hbrnt.User, hbrnt" table="users" lazy="false">


Another workaround is to use the old NHibernate package
nhibernate-1.0.4.0 with this package the issue described above never appears.

Thought about exchanging the castle.dynamic.proxy.dll but this one is of the same build as in package 1.0.4.0 and 1.2.0.GA.

So looks like there is a bug in 1.0.2.0GA which appears in the castle.dynamic.proxy.dll.

Anybody an idea, if it is really a bug or did I made build failure or something ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 19, 2007 9:47 am 
Hibernate Team
Hibernate Team

Joined: Tue Jun 13, 2006 11:29 pm
Posts: 315
Location: Calgary, Alberta, Canada
Perhaps your hbrnt.User class is not public?

_________________
Karl Chu


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 20, 2007 12:28 pm 
Newbie

Joined: Thu Oct 18, 2007 3:16 pm
Posts: 2
Location: Netherlands
yes indeed the class was not public. Checked it out now and it works fine in all cases.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 24, 2007 5:43 am 
Newbie

Joined: Fri Aug 18, 2006 7:30 am
Posts: 5
hace_x wrote:
I had the same problem. the only solution is to switch lazy loading in the mapping file

http://forum.hibernate.org/viewtopic.ph ... namicproxy


The TypeInitializationException occurs for the class itself, not because of a many-to-one relation....

Any ideas ? :-S


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 24, 2007 6:08 am 
Regular
Regular

Joined: Thu Nov 23, 2006 10:29 am
Posts: 106
Location: Belgium
Just to be sure: did you add a reference to the Castle.DynamicProxy.dll assembly in your project ?

_________________
Please rate this post if it helped.

X.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 25, 2007 10:23 am 
Newbie

Joined: Fri Aug 18, 2006 7:30 am
Posts: 5
xasp wrote:
Just to be sure: did you add a reference to the Castle.DynamicProxy.dll assembly in your project ?

:-/
The reference is not needed, but the dll should be in the same directory as the main NHibernate.dll....

That was the answer, thanks.


Top
 Profile  
 
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.