NHibernate works under NUnit and Console but not under IIS [throws PropertyAccessException]
===

I have an API which contains an object which looks like the following:

    public class NOrgUnit {
        public virtual NOrgUnit Parent { get; set;}
        public virtual ISet<NOrgUnit> children { get; set; } // an Iesi 1.0.1 ISet
        public virtual Int64 Id { get; protected set; }
        public virtual string Name { get; set; }

        // etc.
    }

The object has the following map:

    public class NOrgUnitMap : ClassMap<NOrgUnit>
    {
        public NOrgUnitMap()
        {
            Id(x => x.Id);

            Map(x => x.Name);

            References(x => x.Parent).Nullable();
            HasMany(x => x.children).AsSet();
        }
    }

**When I build my API and reference it in a console application, everything works perfectly.**

When I reference the same .dll in an asp.net context (a sitecore project specifically), I receive an NHibernate exception:


    Org Service encountered unexpected exception [NHibernate.PropertyAccessException: Invalid Cast (check your mapping for property type mismatches); setter of TI.Organization.Core.Impl.DAL.Persistence.Entities.Hierarchy.NOrgUnit ---> System.InvalidCastException: Unable to cast object of type 'TI.Security.Core.Impl.Management.Provisioning.DAL.PersistentGenericSet`1[TI.Organization.Core.Impl.DAL.Persistence.Entities.Hierarchy.NOrgUnit]' to type 'Iesi.Collections.Generic.ISet`1[TI.Organization.Core.Impl.DAL.Persistence.Entities.Hierarchy.NOrgUnit]'.
       at (Object , Object[] , SetterCallback )
       at NHibernate.Bytecode.Lightweight.AccessOptimizer.SetPropertyValues(Object target, Object[] values)
       at NHibernate.Tuple.Entity.PocoEntityTuplizer.SetPropertyValuesWithOptimizer(Object entity, Object[] values)
       --- End of inner exception stack trace ---
       at NHibernate.Tuple.Entity.PocoEntityTuplizer.SetPropertyValuesWithOptimizer(Object entity, Object[] values)
       at NHibernate.Tuple.Entity.PocoEntityTuplizer.SetPropertyValues(Object entity, Object[] values)
       at NHibernate.Persister.Entity.AbstractEntityPersister.SetPropertyValues(Object obj, Object[] values, EntityMode entityMode)
       at NHibernate.Engine.TwoPhaseLoad.InitializeEntity(Object entity, Boolean readOnly, ISessionImplementor session, PreLoadEvent preLoadEvent, PostLoadEvent postLoadEvent)
       at NHibernate.Loader.Loader.InitializeEntitiesAndCollections(IList hydratedObjects, Object resultSetId, ISessionImplementor session, Boolean readOnly)
       at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)


This has been stumping me for a few days now. Why would the application work in a console and not in IIS?