11 years ago
BadImageFormatException when running AQTime
I am evaluting AqTime 8.10.772.7
System_ 64 bit, Windows 7, VS 2013. Net 4.5.1, Performance Profile
I am getting BadImageFormatException - BadMethod token exception.
Debug string: Exception cought: (System.InvalidOperationException: There is an error in XML document (0, 0). ---> System.BadImageFormatException: Bad method token.
Debug string: at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializerContract..ctor() 6652 14:11:13:016
Debug string: --- End of inner exception stack trace --- 6652 14:11:13:016
Debug string: at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) 6652 14:11:13:016
Debug string: at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader) 6652 14:11:13:016
Debug string: at Crea.OMSi.Common.Classes.Serialization.XmlToObject2(Byte[] xml, Type type) in
Debug string: at Crea.OMSi.Common.Classes.WsCache.GetFromCache(String key, T& result)
The code, being executed is similar to the following:
string fileName = @"SomeXml.xml";
byte[] data = File.ReadAllBytes(fileName);
Serialization.XmlToObject2(data, typeof(someType));
where XmlToObject2 is used to deserialize the object:
Any ideas om what might be wrong?
This could be related to the fact that .NET is generating Xsml serialization at run time.
Bye,
Matej
System_ 64 bit, Windows 7, VS 2013. Net 4.5.1, Performance Profile
I am getting BadImageFormatException - BadMethod token exception.
Debug string: Exception cought: (System.InvalidOperationException: There is an error in XML document (0, 0). ---> System.BadImageFormatException: Bad method token.
Debug string: at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializerContract..ctor() 6652 14:11:13:016
Debug string: --- End of inner exception stack trace --- 6652 14:11:13:016
Debug string: at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) 6652 14:11:13:016
Debug string: at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader) 6652 14:11:13:016
Debug string: at Crea.OMSi.Common.Classes.Serialization.XmlToObject2(Byte[] xml, Type type) in
Debug string: at Crea.OMSi.Common.Classes.WsCache.GetFromCache
The code, being executed is similar to the following:
string fileName = @"SomeXml.xml";
byte[] data = File.ReadAllBytes(fileName);
Serialization.XmlToObject2(data, typeof(someType));
where XmlToObject2 is used to deserialize the object:
public static object XmlToObject2(byte[] xml, System.Type type)
{
XmlTextReader reader = new XmlTextReader(new MemoryStream(xml));
XmlSerializer serializer = new XmlSerializer(type);
object o = serializer.Deserialize(reader);
return o;
}
This code resides in some other library assemblies, compiled for previous veriosn of .net (4.0).
However, when I try to exctract the above code and run in console application, the exception does not occur.
Any ideas om what might be wrong?
This could be related to the fact that .NET is generating Xsml serialization at run time.
Bye,
Matej