473,396 Members | 1,766 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,396 software developers and data experts.

XML Serialization in dynamically loaded assembly

I am serializing/deserializing a class (Class1) using the XmlSerializer
object in the System.Xml.Serialization namespace in .Net 2.0. Class1 has
some strings and ints and two lists of other simple serializable classes
(Class2 and Class3)

Class1, Class2 and Class3 are defined in an assembly (Assembly1) which is
loaded by another assembly (Assembly2). When I statically reference
Assembly1 in Assembly2, serialization and deserialization work correctly.
When I dynamically load Assembly1 into Assembly2 using 'Assembly.Load',
serialization and deserialization do not work. I get the following error for
serialization:

System.InvalidOperationException: There was an error generating the XML
document. ---System.TypeInitializationException: The type initializer for
'Microsoft.Xml.Serialization.GeneratedAssembly.Xml SerializationWriterClass1'
threw an exception. ---System.NullReferenceException: Object reference not
set to an instance of an object.
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationWriterClass1..cctor()
--- End of inner exception stack trace ---
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationWriterClass1..ctor()
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializerContract.get_Writer()
at System.Xml.Serialization.TempAssembly.InvokeWriter (XmlMapping mapping,
XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String
encodingStyle, String id)
at System.Xml.Serialization.XmlSerializer.Serialize(X mlWriter xmlWriter,
Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)

I am not sure what is happening but I tried pre-generating the serialization
assembly using Sgen and adding a reference to this assembly in Assembly1 but
I still get the same error.

Can anyone advise me what I'm doing wrong here? Thanks!
Sep 30 '08 #1
0 2452

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

Similar topics

0
by: HakonB | last post by:
Hi all I get an exception when trying to deserialize a simple configuration file using XML Serialization. The very long stacktrace can be seen at the bottom of this message. I've see other...
1
by: Benjamin | last post by:
Hi, I'm currently writing a Web Services that interacts with a database. To allow me to use not just one database provider (for example, I could use MS Access, SQL Server or MySQL), the Web...
2
by: Robert Magnusson | last post by:
Hi all, I have a healthy class defined that happily serializes and deserializes from the underlying XML file. The problem I hit is that, as soon as I add an implicit conversion in any of the...
3
by: Michael Hoehne | last post by:
Hi, I'm currently facing a problem with a mixed environment using .NET 1.1 and ..NET 2.0 web services. We have a client application (the "client", system 1) running on .NET 2.0/WinXP, calling...
6
by: mookid8000 | last post by:
Hi group! Is it possible to scan an assembly *which has NOT been added as a reference* for types, and dynamically create instances of the loaded types? I have a program, MyProgram.exe, which...
5
by: Harold Howe | last post by:
I am having a problem deserializing objects from a library when the following conditions exist: 1- The library is strongly named 2- The serialized file was created with version 1.0 of the...
2
by: Smithers | last post by:
Using 3.5, I am stuck in attempting to: 1. Dynamically load an assembly 2. Instantiate a class from that assembly (the client code is in a different namespace than the namespace of the...
2
by: Smithers | last post by:
I have a Windows Forms application that implements a plug-in architecture whereby required assemblies are identified and loaded dynamically. Here are the relevant classes: A = application =...
1
by: Jordan S. | last post by:
I plan to load an assembly during application startup, and load that assembly via reflection (i.e., it isn't referenced in the application's assembly manifest). The assembly will be loaded into the...
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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.