v2.1.0 beta 2 bug under mono 2.4

10 views
Skip to first unread message

Bryan Murphy

unread,
Jun 22, 2009, 6:50:59 PM6/22/09
to nhu...@googlegroups.com
Hey guys,

I'm running into the a problem compiling our hbm files under Mono v2.4 and NHibernate v2.1.0 beta 2.  Looking through the code, it looks like the problem is how the XmlSerializer interprets AbstractDecoratable and the culprits are the properties MappedMetaData and InheritableMetaData.  The exception I'm getting is below.

Thanks,
Bryan

NHibernate.MappingException: Could not compile the mapping document: **SNIP**.Domain.hbm.xml ---> System.InvalidOperationException: There was an error reflecting type 'NHibernate.Cfg.MappingSchema.HbmMapping'. ---> System.InvalidOperationException: To be XML serializable, types which inherit from ICollection must have an implementation of Add(System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[NHibernate.Mapping.MetaAttribute, NHibernate, Version=2.1.0.2002, Culture=neutral, PublicKeyToken=aa95f207798dfdb4]]) at all levels of their inheritance hierarchy. System.Collections.Generic.IDictionary`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[NHibernate.Mapping.MetaAttribute, NHibernate, Version=2.1.0.2002, Culture=neutral, PublicKeyToken=aa95f207798dfdb4]] does not implement Add(System.Collections.Generic.KeyValuePair`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[NHibernate.Mapping.MetaAttribute, NHibernate, Version=2.1.0.2002, Culture=neutral, PublicKeyToken=aa95f207798dfdb4]]).
  at System.Xml.Serialization.TypeData.get_ListItemType () [0x00230] in /root/mono2.4/mono-2.4/mcs/class/System.XML/System.Xml.Serialization/TypeData.cs:342
  at System.Xml.Serialization.TypeData.get_ListItemTypeData () [0x00016] in /root/mono2.4/mono-2.4/mcs/class/System.XML/System.Xml.Serialization/TypeData.cs:274
  at System.Xml.Serialization.TypeData..ctor (System.Type type, System.String elementName, Boolean isPrimitive, System.Xml.Serialization.TypeData mappedType, System.Xml.Schema.XmlSchemaPatternFacet facet) [0x00104] in /root/mono2.4/mono-2.4/mcs/class/System.XML/System.Xml.Serialization/TypeData.cs:94
  at System.Xml.Serialization.TypeData..ctor (System.Type type, System.String elementName, Boolean isPrimitive) [0x00000] in /root/mono2.4/mono-2.4/mcs/class/System.XML/System.Xml.XPath/Parser.cs:1
  at System.Xml.Serialization.TypeTranslator.GetTypeData (System.Type runtimeType, System.String xmlDataType) [0x00241] in /root/mono2.4/mono-2.4/mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs:243
  at System.Xml.Serialization.TypeTranslator.GetTypeData (System.Type type) [0x00000] in /root/mono2.4/mono-2.4/mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs:163
  at System.Xml.Serialization.XmlReflectionImporter.GetReflectionMembers (System.Type type) [0x00244] in /root/mono2.4/mono-2.4/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs:774
  at System.Xml.Serialization.XmlReflectionImporter.ImportClassMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x0007a] in /root/mono2.4/mono-2.4/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs:343
  at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x0006e] in /root/mono2.4/mono-2.4/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs:217
  --- End of inner exception stack trace ---
  at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Xml.Serialization.TypeData typeData, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00179] in /root/mono2.4/mono-2.4/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs:237
  at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping (System.Type type, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x0003c] in /root/mono2.4/mono-2.4/mcs/class/System.XML/System.Xml.Serialization/XmlReflectionImporter.cs:192
  at System.Xml.Serialization.XmlSerializer..ctor (System.Type type, System.Xml.Serialization.XmlAttributeOverrides overrides, System.Type[] extraTypes, System.Xml.Serialization.XmlRootAttribute root, System.String defaultNamespace) [0x00047] in /root/mono2.4/mono-2.4/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs:226
  at System.Xml.Serialization.XmlSerializer..ctor (System.Type type) [0x00000] in /root/mono2.4/mono-2.4/mcs/class/System.XML/System.Xml.XPath/Parser.cs:1
  at NHibernate.Cfg.XmlHbmBinding.Binder.Deserialize[HbmMapping] (System.Xml.XmlNode node) [0x00000]
  at NHibernate.Cfg.XmlHbmBinding.MappingRootBinder.Bind (System.Xml.XmlNode node) [0x00000]
  at NHibernate.Cfg.Configuration.AddValidatedDocument (NHibernate.Cfg.NamedXmlDocument doc) [0x00000]
  --- End of inner exception stack trace ---

Luca Del Tongo

unread,
Jun 25, 2009, 6:16:58 AM6/25/09
to nhusers
I'm facing the same problem as Bryan stated, with the same
configuration.
Any ideas?

Ricardo

unread,
Jul 5, 2009, 6:51:27 PM7/5/09
to nhusers
I'm getting the same issue running NHibernate on Mono with Linux (but
not with Windows for some reason). Attempted to raise a defect with
NHibernate JIRA:

http://nhjira.koah.net/browse/NH-1865

But my issue was closed almost immediately, and I'm still none the
wiser as to the cause:

"The problem, may be, was caused by some not serializable classes (now
serializable).
If that was not the problem please add the issue to the Mono issue
tracker because Mono should work as .NET."

Does this mean that defects with NHibernate on Mono should never be
raised against NHibernate because "Mono should work as .NET"?

On Jun 25, 11:16 am, Luca Del Tongo <luk...@gmail.com> wrote:
> I'm facing the same problem as Bryan stated, with the same
> configuration.
> Any ideas?
>
> On Jun 23, 12:50 am, Bryan Murphy <bmurphy1...@gmail.com> wrote:
>
> > Hey guys,
> > I'm running into the a problem compiling our hbm filesunderMonov2.4 and
> > NHibernatev2.1.0beta2.  Looking through the code, it looks like the

Fabio Maulo

unread,
Jul 5, 2009, 7:23:25 PM7/5/09
to nhu...@googlegroups.com
No that mean that mean that if you can prove that the cause is inside NH and we can do something ok.
If you can't prove that the problem is inside NH well... you should find the place where create the issue.
NH's is for NH issues and not for mono isees nor for DataProvider issues nor RDBMS issues and so on.

Btw Mono should work at least as NET.
When a framework is working without problems on windows and has a problem in Mono the most probably is an issue in Mono, and Mono's users should help to improve it and not asking workaround everywhere.

2009/7/5 Ricardo <ricardo....@gmail.com>



--
Fabio Maulo

Ricardo Gladwell

unread,
Jul 6, 2009, 5:28:19 AM7/6/09
to nhu...@googlegroups.com
2009/7/6 Fabio Maulo <fabio...@gmail.com>:

> No that mean that mean that if you can prove that the cause is inside NH and
> we can do something ok.

Not being an expert in NHibernate architecture, how exactly should I
go about "proving" this? Some more information here would be helpful.

> If you can't prove that the problem is inside NH well... you should find the
> place where create the issue.

This doesn't seem very helpful: isn't the NHibernate team interested
in seeing NHibernate working on Mono?

> When a framework is working without problems on windows and has a problem in
> Mono the most probably is an issue in Mono, and Mono's users should help to
> improve it and not asking workaround everywhere.

I must admit, I'm not sure I understand your attitude: the bug was
being seemed to be thrown from a call to the NHibernate framework, so
the first place I raised it was with you guys. This seems like a
reasonable first step to me, and I don't see how this is "asking
workaround everywhere."

If the issue is with Mono, it would be helpful if you could point me
in the right direction, letting me know which Mono/System/NHibernate
class is causing the problem. We all benefit if I can find the right
result and raise it with the correct people.

Sincerely...

-- Ricardo Gladwell

deil

unread,
Jul 6, 2009, 5:19:03 AM7/6/09
to nhusers
Hello guys,

I have the same issue.
And think the problem is not inside NH:
It uses IDictionary<string, MetaAttribute> and Mono, according to
sources, thinks that to be serializable, it should have a method Add
(KeyValuePair<string, MetaAttribute>), but can't find it through
reflection. But as IDictionary<TKey, TValue> is defined as extending
ICollection<KeyValuePair<TKey, TValue>>, this method should exist. So,
the problem is somewhere inside Mono's reflection or Xml serialization
code.
I need some more time to understand all it completely

Dario Quintana

unread,
Jul 6, 2009, 6:05:44 AM7/6/09
to nhu...@googlegroups.com
The issue was closed because:

1) Opened as critical, later was changed, and Critical means: NHibernate can't work without this issue working.
2) Absence of a simple test case to reproduce the problem.
3) The issue seems to be on Mono side, and not in NHibernate.

I counted 3 people saying that are experimenting this issue, you guys should join together, create a test-case and send to the Mono team. I don't know how this can be a problem.
--
Dario Quintana
http://darioquintana.com.ar

Ricardo Gladwell

unread,
Jul 6, 2009, 6:36:27 AM7/6/09
to nhu...@googlegroups.com
Hi Dario,

To explain, the problem here was that:

1. The issue was marked closed and I was told to raise it somewhere
but I still don't understand why NHibernate is failing on Mono, so
what exactly am I supposed to raise with Mono?
2. For Mono users I guess the issue is Critical. If it can be
downgraded that's fine, but I don't understand why that means it
should be closed.

I'm not sure I understand the hostility at this particular project.
I'll try some other ORM framework.

Good luck..

Ricardo Gladwell <ricardo....@gmail.com>



2009/7/6 Dario Quintana <cont...@darioquintana.com.ar>:

Dario Quintana

unread,
Jul 6, 2009, 7:10:51 AM7/6/09
to nhu...@googlegroups.com
Hi Ricardo.

Take it easy Ricardo, nobody is being hostile here :)

I my opinion it's a Mono problem, and you should create an issue here http://mono-project.com/Bugs.
If it's a Mono bug, there is nothing we can do. Or Maybe if we find the problem, we can workaround it, but I don't think is a good idea, Mono is a open source project, so like NHibernate you can report this issue and wait to the commiters fix the problems, and with a patch this may go faster.

I hope this clarify the situation.
Cheers

On Mon, Jul 6, 2009 at 7:36 AM, Ricardo Gladwell <ricardo....@gmail.com> wrote:

Hi Dario,

 To explain, the problem here was that:

1. The issue was marked closed and I was told to raise it somewhere
but I still don't understand why NHibernate is failing on Mono, so
what exactly am I supposed to raise with Mono?
2. For Mono users I guess the issue is Critical. If it can be
downgraded that's fine, but I don't understand why that means it
should be closed.

I'm not sure I understand the hostility at this particular project.
I'll try some other ORM framework.

Good luck..

Ricardo Gladwell <ricardo....@gmail.com>


--

Fabio Maulo

unread,
Jul 6, 2009, 10:04:58 AM7/6/09
to nhu...@googlegroups.com
2009/7/6 Ricardo Gladwell <ricardo....@gmail.com>


I'll try some other ORM framework.
 Good luck..

Good solution!

I hope that all OpenSource users does not have your attitude, instead I hope all has the Anton's attitude (Anton aka "deil" see mail above).
Thanks Anton to investigate the problem: try to recreate it with a test and then send the test to Mono team.
--
Fabio Maulo

deil

unread,
Jul 7, 2009, 7:00:44 AM7/7/09
to nhusers
Hello again,

I have managed to patch Mono and get NH trunk up & running!
Now I will try to create a reproducable test and send it to Mono team.

Fabio Maulo

unread,
Jul 7, 2009, 8:29:55 AM7/7/09
to nhu...@googlegroups.com
Well done Antón!!
Thanks.

2009/7/7 deil <an...@tinuviel.ru>


Hello again,

I have managed to patch Mono and get NH trunk up & running!
Now I will try to create a reproducable test and send it to Mono team.




--
Fabio Maulo

curt

unread,
Jul 11, 2009, 2:37:08 PM7/11/09
to nhusers
Ah beautiful! I can't wait to get this running again on mono.

Thanks!
Curtis.

Patrick McEvoy

unread,
Jul 13, 2009, 1:05:55 PM7/13/09
to nhusers
dell, can you post the patch or provide link to mono bugzilla?

Ricardo has created an issue on mono bugzilla and the mono guys have
an interesting response....

----
This repro (and then likely NHibernate) makes nasty use of .NET
exploit that
inconsistently allows "dictionary serialization" which is explicitly
prohibited.

It is proved when the sample repro is modified to hold
"Dictionary<string,string>" instead of "IDictionary<string,string>",
then .NET
raises InvalidOperationException.

Our serialization engine is designed to explicitly to exclude such
dictionary
serialization.

We may have to fix some ICollection-based serialization, but such use
won't be
popular (->MINOR), and it is absolutely not for this kind of
IDictionary<,>
use.
----

https://bugzilla.novell.com/show_bug.cgi?id=519442

Patrick McEvoy

unread,
Jul 18, 2009, 11:33:12 AM7/18/09
to nhusers
This needs re-opening (NH-1865)... [XmlIgnore] are in the wrong
places. They should be here...

[XmlIgnore]
public virtual IDictionary<string, MetaAttribute> MappedMetaData
{

[XmlIgnore]
public IDictionary<string, MetaAttribute> InheritableMetaData
{

On Jul 13, 6:05 pm, Patrick McEvoy <patrick.mce...@gmail.com> wrote:
> dell, can you post the patch or provide link tomonobugzilla?
>
> Ricardo has created an issue onmonobugzilla and themonoguys have
> an interesting response....
>
> ----
> This repro (and then likely NHibernate) makes nasty use of .NET
> exploit that
> inconsistently allows "dictionary serialization" which is explicitly
> prohibited.
>
> It is proved when the sample repro is modified to hold
> "Dictionary<string,string>" instead of "IDictionary<string,string>",
> then .NET
> raises InvalidOperationException.
>
> Our serialization engine is designed to explicitly to exclude such
> dictionary
> serialization.
>
> We may have to fix some ICollection-based serialization, but such use
> won't be
> popular (->MINOR), and it is absolutely not for this kind of
> IDictionary<,>
> use.
> ----
>
> https://bugzilla.novell.com/show_bug.cgi?id=519442
>
> On Jul 7, 12:00 pm, deil <an...@tinuviel.ru> wrote:
>
> > Hello again,
>
> > I have managed to patchMonoand get NH trunk up & running!

Fabio Maulo

unread,
Jul 18, 2009, 2:45:50 PM7/18/09
to nhu...@googlegroups.com
Ok.

2009/7/18 Patrick McEvoy <patrick...@gmail.com>



--
Fabio Maulo

deil

unread,
Jul 19, 2009, 6:03:15 AM7/19/09
to nhusers
Hello guys,

It's good that I've been on the vacations =)
As it seems that the bug is not in Mono, but in NH.

So, the correct fix for this issue is in [XmlIgnore] position and svn
version should work fine?
Reply all
Reply to author
Forward
0 new messages