G
Guest
hi ,
I had asked this question serveral days ago, but it's still unresolved. And
I have found some new things. this error just occured sometimes,not always.
the code like this:(It's running in a VS IED Add-In.)
public static Mapping Deserialize(string strXmlFilePath)
{
XmlSerializer s = new XmlSerializer(typeof(Mapping));
using (StreamReader sr = new StreamReader(strXmlFilePath))
{
object o = s.Deserialize(sr);
Type t = o.GetType();
Type t2 = typeof(Mapping);
Mapping m = (Mapping)o;
return m;
}
}
--------------------when the exception is
catched------------------------------------------
Now, I catch the exception in the debuger: variable o references to a
instance of Mapping class, but the sentence Mapping m = (Mapping)o throw a
InvalidCastException.
and:
t.Assembly.CodeBase
"file:///c:/documents and settings/whf.ztlq/application
data/microsoft/visualstudio/7.1/projectassemblies/51an1oxl01/persistlayer.dll"
t2.Assembly.CodeBase
"file:///D:/MyPersistLayer/ORMappingGenerator/ORMappingGenerator/bin/PersistLayer.DLL"
t ==t2
fals
-------------------------------------------------------------------------------------------
---------------when it run
correctly-----------------------------------------------------
t.Assembly.CodeBase
"file:///D:/MyPersistLayer/ORMappingGenerator/ORMappingGenerator/bin/PersistLayer.DLL"
t2.Assembly.CodeBase
"file:///D:/MyPersistLayer/ORMappingGenerator/ORMappingGenerator/bin/PersistLayer.DLL"
t ==t2
true
--------------------------------------------------------------------------------------------
Any body can tell me why?
thanks
WangHF
I had asked this question serveral days ago, but it's still unresolved. And
I have found some new things. this error just occured sometimes,not always.
the code like this:(It's running in a VS IED Add-In.)
public static Mapping Deserialize(string strXmlFilePath)
{
XmlSerializer s = new XmlSerializer(typeof(Mapping));
using (StreamReader sr = new StreamReader(strXmlFilePath))
{
object o = s.Deserialize(sr);
Type t = o.GetType();
Type t2 = typeof(Mapping);
Mapping m = (Mapping)o;
return m;
}
}
--------------------when the exception is
catched------------------------------------------
Now, I catch the exception in the debuger: variable o references to a
instance of Mapping class, but the sentence Mapping m = (Mapping)o throw a
InvalidCastException.
and:
t.Assembly.CodeBase
"file:///c:/documents and settings/whf.ztlq/application
data/microsoft/visualstudio/7.1/projectassemblies/51an1oxl01/persistlayer.dll"
t2.Assembly.CodeBase
"file:///D:/MyPersistLayer/ORMappingGenerator/ORMappingGenerator/bin/PersistLayer.DLL"
t ==t2
fals
-------------------------------------------------------------------------------------------
---------------when it run
correctly-----------------------------------------------------
t.Assembly.CodeBase
"file:///D:/MyPersistLayer/ORMappingGenerator/ORMappingGenerator/bin/PersistLayer.DLL"
t2.Assembly.CodeBase
"file:///D:/MyPersistLayer/ORMappingGenerator/ORMappingGenerator/bin/PersistLayer.DLL"
t ==t2
true
--------------------------------------------------------------------------------------------
Any body can tell me why?
thanks
WangHF