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.  [ 1 post ] 
Author Message
 Post subject: Exception loading Castle.DynamicProxy.dll : known error?
PostPosted: Wed Sep 19, 2007 6:47 am 
Beginner
Beginner

Joined: Thu Oct 26, 2006 4:45 am
Posts: 39
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" schema="dbo">

   <class name="Airtrade.Business.Locations.ProviderLocation, Airtrade.Business.Locations" table="Provider_Location" lazy="true">
      <id name="Id" type="Int32" column="ProviderLocationId">
         <generator class="identity" />
      </id>

      <property name="ProviderLocationCode" column="ProviderLocationCode" type="String" />

      <component name="GeoCoordinate" class="Airtrade.Business.GeoCoordinate, Airtrade.Business">
         <property name="Latitude" column="Latitude"  type="double"  />
         <property name="Longitude" column="Longitude" type="double" />
      </component>

      <many-to-one name="Provider" column="ProviderId" class="Airtrade.Business.Provider, Airtrade.Business" lazy="proxy"/>

   </class>

</hibernate-mapping>


Hi,

for the above mapping I ran into the evil error:


NHibernate An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

NOTE That this error does not occur when changing lazy="proxy" to lazy="false" for the many-to-one relation!


The code that results in the error is when a list of child-elements is read for a parent-object that is already read by NHibernate:

First the parent is read:

Code:

ICriteria locationCriteria = session.CreateCriteria(typeof(Location));
locationCriteria.Add(Expression.Eq("Id", locationId));
location = (Location)locationCriteria.UniqueResult();




Now when the childs of location are read it goes wrong:



Code:
public List<ProviderLocation> GetProviderLocations(Location location, Range range)
        {
            // The list that is returned
            List<ProviderLocation> providerLocationsInRadius = new List<ProviderLocation>();

            try
            {
                // setup the criteria
                ICriteria criteria = AirtradeSession.CurrentSession.CreateCriteria(typeof (ProviderLocation));

                if (range.LeftlongitudeLine < range.RightlongitudeLine)
                {
                    criteria.Add(Expression.Ge("GeoCoordinate.Longitude", range.LeftlongitudeLine));
                    criteria.Add(Expression.Le("GeoCoordinate.Longitude", range.RightlongitudeLine));
                }
                else
                {
                    criteria.Add(Expression.Le("GeoCoordinate.Longitude", (range.LeftlongitudeLine)));
                    criteria.Add(Expression.Ge("GeoCoordinate.Longitude", (range.RightlongitudeLine)));
                   
                }

                if (range.BottomLatitudeLine < range.TopLatitudeLine)
                {
                    criteria.Add(Expression.Ge("GeoCoordinate.Latitude", range.BottomLatitudeLine));
                    criteria.Add(Expression.Le("GeoCoordinate.Latitude", range.TopLatitudeLine));
                }
                else
                {
                    criteria.Add(Expression.Le("GeoCoordinate.Latitude", range.BottomLatitudeLine));
                    criteria.Add(Expression.Ge("GeoCoordinate.Latitude", range.TopLatitudeLine));
                }

                //discard empty entries in the table:
                criteria.Add(Expression.IsNotNull("ProviderLocationCode"));

criteria.SetResultTransformer(new NHibernate.Transform.DistinctRootEntityResultTransformer());
               
   
                // move restults from NHibernate to generic list
                // this call fails if lazy=true
                List<ProviderLocation> providerLocations = new List<ProviderLocation>(criteria.List<ProviderLocation>());
...




I debugged the NHibernate source-code and this is happening when NHibernate is trying to load Castle.DynamicProxy (CastleFactory)

The error occurs in
NHibernate.Proxy.CastleProxyFactory.cs
line 52 / 56

Is this a known error??

Has anybody tried the fix presented by MS on 11 Jul 2007 ?
http://support.microsoft.com/kb/928208

or is there any other way to circumvent this issue?


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

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.