473,385 Members | 1,427 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

XmlSerializer uses different type/assembly than running code - completelylost

Hi all

I have a strange situation with a VS.net Add-In that uses the
XmlSerializer class for deserialization. In the code below, I pass a
given type to the serializer class. However, the type of the object that
is returned by the serializer is a different one so I can't get a
reference to it (casts fail).
//get the type -> same problem with typeof(...)
MappedObjectNode node = new MappedObjectNode();
Type type = node.GetType();

//store assembly location
string loc1 = type.Assembly.Location;

XmlSerializer serializer = new XmlSerializer(type);
using (Stream stream = file.OpenRead())
{
//perform deserialization
object obj = serializer.Deserialize(stream);

//get assembly location
string loc2 = obj.GetType().Assembly.Location;
}
When running this code, the strings loc1 and loc2 are different. VS.net
creates some kind of shadow copies for the add-in. However, the
serializer and the add-in use different assemblies:
loc1 (object created in add-in):
c:\dokumente und einstellungen\sumi\
lokale einstellungen\anwendungsdaten\assembly\
dl2\2dao39nh.tnl\4ehanxn5.m8y\
3bed8731\d814a9c3_828fc401\dao.net.dll

loc2 (object created by serializer):
c:\dokumente und einstellungen\sumi\
anwendungsdaten\microsoft\visualstudio\7.1\
projectassemblies\qcwp2ofq01\dao.net.dll
Strange enough, if I don't touch my solution and immediately open the
add-in, the copy within the "visualstudio\7.1"-folder is not being used
(loc1 and loc2 are the same as loc1 above) and my cast succeeds. This
works fine for me, but the add-in is part of an open-source project
which will hopefully be used by many people...

Right now, I'm stuck - any suggestion is highly appreciated

Thanks for your advice

Philipp
Nov 16 '05 #1
0 1347

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chris Aitchison | last post by:
Hello, I am attempting to have a class that I have written serialize so that it can be both passed as a parameter or return value for a webservice, and also be serialized to disk using the...
0
by: Magnus Lindhe | last post by:
Hello, I'm trying to deserialize an XML document into a objects with the XmlSerializer which works fine in my NUnit test suit but fails with a TypeLoadException in the server. The difference...
4
by: Andy Neilson | last post by:
I've run across a strange behaviour with XmlSerializer that I'm unable to explain. I came across this while trying to use XmlSerializer to deserialize from a the details of a SoapException. This...
12
by: SJD | last post by:
I've just read Christoph Schittko's article on XmlSerializer: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxmlnet/html/trblshtxsd.asp . . . and very informative it is too....
1
by: Vladimir Semenov | last post by:
Hi, I'm trying to serialize a type contained in assembly referering to another assembly in GAC. XmlSerializer xs = new XmlSerializer( typeof(TransferParentData ) ); The code above throws...
3
by: Don McNamara | last post by:
Hi, I've hit quite a strange problem with XmlSerializer on my W2K3 server. When I serialize/deserialize using an exe on my local computer (XP), everything works fine. When I put the code out on...
4
by: BuddyWork | last post by:
Hello, When running the following line of code XmlSerializer serializer = new XmlSerializer(typeof (MyXmlTestClass)); I get the following exception message. An unhandled exception of
0
by: awood45 | last post by:
I ran into a bizarre crashing of one of my programs earlier today, and noticed my IE 6 was messed up (maybe this is important, maybe it isn't, but it coincided with this not working). After fixing...
2
by: christopher.watford | last post by:
I'm loading a plugin assembly using Activator.CreateInstanceFrom, and inside this assembly is a settings class which gets serialized to XML. The general code flow is as follows: ObjectHandle...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.