Click here to Skip to main content
Click here to Skip to main content
Alternative Tip/Trick

Tagged as

Get rid of XmlInclude when using XmlSerializer

, 17 Nov 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
The above solution made me grin as it helped me solved my serialization puzzle. However, if you have an extensible format with components spread over multiple assemblies, this solution may not pick up all the types.I brute force it as follows:List knownTypes = new...

The above solution made me grin as it helped me solved my serialization puzzle. However, if you have an extensible format with components spread over multiple assemblies, this solution may not pick up all the types.

I brute force it as follows:

List<type> knownTypes = new List<type>();
 
foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
{
    knownTypes.AddRange(Assembly.GetExecutingAssembly().GetTypes().Where(
    t => typeof(XMLBinaryPackageInfo).IsAssignableFrom(t)));
}

My rationale is that this code is unlikely to be called often enough to worry about enumerating such a potentially vast number of types. I don't cache this stuff but you can keep track of assembly loading / unloading if you must. Mileage may vary!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Gusdor
Web Developer
United Kingdom United Kingdom
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141223.1 | Last Updated 17 Nov 2011
Article Copyright 2011 by Gusdor
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid