chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
I have traced a problem down to TypeMock but not sure how extensive the problem is. All the issues started popping up with the latest source of NHibernate from the trunk so I thought the issue was there. Basically running the unit tests for NHibernate would produce an error similiar to this.

NHibernate.Test.CfgTest.ConfigurationFixture.CacheConfiguration : NHibernate.MappingException : Could not compile the mapping document: NHibernate.DomainModel.ABC.hbm.xml

  ----> System.InvalidOperationException : There is an error in XML document (0, 0).

  ----> System.InvalidProgramException : Common Language Runtime detected an invalid program.


basically its an issue with the XmlSerializer and TypeMock. After working with the NHibernate team and nobody could reproduce the error, I found this post http://forums.microsoft.com/MSDN/ShowPo ... 5&SiteID=1

The reporter ultimately figured out that uninstalling TypeMock fixed the problem. I simply disabled TypeMock from Vs.Net and that resolved the problem. ReEnabled TypeMock and the problem returned.

The issue seems to stem from a conflict between TypeMock and The XmlSerializer because the issue the NHibernate tests are with the XmlSerializer just as the poster describes in the link above.

Partial stack from NHibernate is

       at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializerContract..ctor()

          --- End of inner exception stack trace ---

       at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)

       at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)

       at System.Xml.Serialization.XmlSerializer.Deserialize(TextReader textReader)

       at NHibernate.Cfg.XmlHbmBinding.Binder.Deserialize[T](XmlNode node)


I saw that there are other issues with the CLR detecting an Invalid program and TypeMock on this forum. Hopefully this issue is being fixed. Otheriwse, let me know if I can provide more information to get this issue resolved.

Jesse
asked by juice_johnson (9.8k points)

33 Answers

0 votes
Hi Jesse,

Thanks for offering your help. Let's take this offline - I'l write a separate mail.
answered by gilz (14.5k points)
0 votes
We are having the exact same issue. NHibernate and typemock does not work in mconjunction with eachother when using XML Mapping documents. Can I get in on this?

mattias [at] fatstatement dottcomm
answered by M. Johansson (2.2k points)
0 votes
Hi
Tanks for reporting.
We will update you about what's going on with this issue as well.
answered by ohad (35.4k points)
0 votes
Hi,

I am using TypeMock and experiencing similar issues.

We are using nant to run our build. Nunit running tests and TypeMock version 4.1.0.0. We are running ncover for code coverage.

Please can you include me on an update on this thread.
Dean_vr at yahoo dot com

Running tests in resharper pass. Running builds with tests that use XmlSerializer Serialize fail with error:

[exec] at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterResultSet1.Write18_ResultSetOfSupplier(Object o)[exec] 2) RetrieveSupplierVenuePageDetails : System.InvalidOperationException : There was an error generating the XML document.[exec] ----> System.InvalidProgramException : Common Language Runtime detected an invalid program.[exec] at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)[exec] at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle)[exec] at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces)[exec] at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o)[exec] at SerializeObject(Object pObject) in WebServiceHelperTest.cs:line 2508[exec] at RetrieveSupplierVenuePageDetails() in WebServiceHelperTest.cs:line 2288[exec] --InvalidProgramException[exec] at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterResultSet1.Write6_Currency(String n, String ns, Currency o, Boolean isNullable, Boolean needType)[exec] at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterResultSet1.Write8_SupplierPackage(String n, String ns, SupplierPackage o, Boolean isNullable, Boolean needType)[exec] at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterResultSet1.Write16_Supplier(String n, String ns, Supplier o, Boolean isNullable, Boolean needType)[exec] at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterResultSet1.Write17_ResultSetOfSupplier(String n, String ns, ResultSet`1 o, Boolean isNullable, Boolean needType)[exec] at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterResultSet1.Write18_ResultSetOfSupplier(Object o)
answered by dean2008 (960 points)
0 votes
ps. this is the line of code it dies on:


      private static String SerializeObject(Object pObject) {
         MemoryStream memoryStream = new MemoryStream();
         XmlSerializer xs = new XmlSerializer(pObject.GetType());
         XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
         xs.Serialize(xmlTextWriter, pObject); // dies here
         memoryStream = (MemoryStream) xmlTextWriter.BaseStream;
         string xmlString = UTF8ByteArrayToString(memoryStream.ToArray());
         return xmlString;
      }


not sure if this is an nant issue or typemock...

thanks!
answered by dean2008 (960 points)
0 votes
Hi,

Thanks for reporting this. The more information we have, we can help resolve this. We'll keep everyone updated on this issue.
answered by gilz (14.5k points)
0 votes
Hi,

do you have a rough eta on this?

thanks,
answered by dean2008 (960 points)
0 votes
Hi,

do you have a rough eta on this?

thanks,


I second this. Our test suite is effectively broken due to this, because we cannot run database tests in live mode. It's VERY critical for us.
answered by M. Johansson (2.2k points)
0 votes
Hi
This issue is high in our list.
I can't really know when it will be fixed since we are still trying duplicate the error. :(
answered by ohad (35.4k points)
0 votes
juice_johnson: I'm having trouble reproducing this error. At least for now, it does not seem to reproduce with a simple XMLSerializer, so we need to find the cause a little higher up in the chain.
Can you post some piece of code that will reproduce this? A test that uses NHibernate would be great.

Roy
answered by royo (2k points)
...