Forgot to specify some details:
 - NHibernate trunk (today)
 - VS 2010  & NET 4.0, Windows 7 x64.
 - proxy factories: linfu & castle.


On Fri, Aug 13, 2010 at 4:21 PM, Valeriu Caraulean <[email protected]>wrote:

> I've got into situation where my mappings and domain are throwing to me a
> FatalExecutionEngineError.
> I'll be posting the code here, hoping that someone can help me understand,
> I'm doing "unnatural" things with NHibernate or it's a bug somewhere...
>
> The exact error I'm getting is:
>
> *FatalExecutionEngineError was detected*
>
> Message: The runtime has encountered a fatal error. The address of the
> error was at 0xf8a213a3, on thread 0x660. The error code is 0xc0000005. This
> error may be a bug in the CLR or in the unsafe or non-verifiable portions of
> user code. Common sources of this bug include user marshaling errors for
> COM-interop or PInvoke, which may corrupt the stack.
>
> Example is stripped down to minimum from our project. Names are awkward,
> scenario probably looks silly, but that's extracted from our real domain.
> I'm showing only relevant part of classes. For full VS project see
> http://github.com/vcaraulean/NHibernate.FEEE .
>
> *Domain*: two classes with one-to-many relation. Classes are "aggregate
> roots", modified individually but in same session/transaction scope. Using
> double dispatch to keep aware one of another.
>
> public class First
> {
> public First(Second second)
> {
> Second = second;
> }
>
> private Second second;
> public virtual Second Second
> {
> get { return second; }
> private set
> {
> second = value;
> second.AddFirst(this);
> }
> }
> }
>
> public class Second
> {
> private readonly List<First> collectionOfFirsts;
>
> public Second()
> {
> collectionOfFirsts = new List<First>();
> }
>
> public virtual IEnumerable<First> CollectionOfFirsts
> {
> get { return collectionOfFirsts; }
> }
>
> public virtual void AddFirst(First first)
> {
> collectionOfFirsts.Add(first); *// Here FatalExecutionEngineError is
> thrown*
> }
> }
>
> *Mapping files, FluenNHibernate:*
>
> public class FirstPersistenceMap : ClassMap<First>
> {
> public FirstPersistenceMap()
> {
> Id(x => x.Id);
> References(x => x.Second);
> }
> }
>
> public class SecondPersistenceMap : ClassMap<Second>
> {
> public SecondPersistenceMap()
> {
> Id(x => x.Id);
> HasMany(x => x.CollectionOfFirsts)
> .Access.ReadOnlyPropertyThroughCamelCaseField();
> }
> }
>
> *Usage, in unit test:*
>
> using (var session = sessionFactory.OpenSession())
> using (var tx = session.BeginTransaction())
> {
> var second = new Second();
> session.Save(second);
>
> var firstClass = new First(second);
> session.Save(firstClass);
> }
>
> Two questions:
>  - What I'm doing wrong here?
>  - How can I map it so it will work as expected?
>
> Thanks!
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to