Loading WCF Client Configuration from Different Files with ConfigurationChannelFactory

One pain point with configuration that WCF developers have run into in previous versions of the framework is the limitation that WCF clients can only use the hosting executable’s configuration file. This can be problematic for clients that need to call multiple services because the configuration for all of these services would have to be…

5

Turning XML into XmlSerializer CLR Types with xsd.exe

Here’s a common dilemma .NET developers encounter when working with XML: I have some XML that I want to represent in a strongly typed way, but I don’t have any XSDs to represent that XML. How do I turn that XML into CLR types that I can serialize?   Of course, I could go about…

0

Using XML Schema Import and Export for XmlSerializer

In a previous post, I outlined how you could import and export the XML schema for a type that you’re serializing with DataContractSerializer. Here’s how to do the same thing if you’re serializing objects with XmlSerializer:   static void RoundTripXmlMetadata(Type type) {     XmlSchemas schemas = new XmlSchemas();     XmlSchemaExporter exporter = new XmlSchemaExporter(schemas);  …

0

How to get minOccurs = 0 in the schema for XmlSerializer struct members

If you try exporting the following type into an XML schema:   public class Employee {     public DateTime BirthDate { get; set; } }   And you happen to be using XmlSerializer, you may be surprised to find that the schema gets exposed like this:   <xs:schema elementFormDefault=”qualified” xmlns:xs=”http://www.w3.org/2001/XMLSchema”>   <xs:element name=”Employee” nillable=”true” type=”Employee”…

6

How to Change .NET Configuration Files at Runtime (including for WCF)

One of the most common issues people run into with WCF configuration, and .NET applications in general, is that configuration files appear to be fixed. You only have one configuration file for an executable, and you can’t use different configuration files as your exe.config while the application is running. Of course, you can always shut…

5