Accessing multiple .Net generated libraries from a single client can cause issues with the use of the static Default SerializationContext and other static data.
Symptom
When you run the application you get an Exception as follows (where BookStoreLib is your library and "xs" is the duplicate prefix):
System.TypeInitializationException was unhandled
HResult=-2146233036
Message=The type initializer for 'BookStoreLib.Registration' threw an exception.
Source=BookStoreLib
InnerException: System.ArgumentException
HResult=-2146233088
Message=An entry for the prefix 'xs' has already been registered.
Source=LiquidTechnologies.Runtime
Cause
This issue is by design as it highlights namespace clashes which may be a problem when using the libraries.
Resolution
There are a number of options to work around this issue.
Option 1: (Best Option)
The simplest fix for this is to generate only 1 library by creating a super schema which imports your other schema:
Option 2:
Remove usage of the SerializationContext.Default as this is a static class which would be used across all libraries.
To do this, open file Enumerations.cs, and comment out all lines within the ##HAND_CODED_BLOCK that add NamespaceAliases etc. to the SerializationContext.Default and instead create a library specific SerializationContext.
e.g. Create your own static:
static public LiquidTechnologies.Runtime.SerializationContext myLibraryAContext = new LiquidTechnologies.Runtime.SerializationContext();
...
// add default namespace
myLibraryAContext.NamespaceAliases.Add("xs", "http://www.w3.org/2001/XMLSchema-instance", true);
// add your own namespaces
myLibraryAContext.NamespaceAliases.Add("...", "...", true);
Now anytime you call ToXML... and FromXml... methods within your code, you need to also pass myLibraryAContext as a parameter.
You would replicate this for library B, C, D.
Option 3:
Depending on your schemas, you may be able to get away with just changing the way the SerializationContext .Default namespace items are added.
To do this, open file Enumerations.cs and change all lines within the ##HAND_CODED_BLOCK such as:
LiquidTechnologies.Runtime.SerializationContext.Default.NamespaceAliases.Add("xs", "http://www.w3.org/2001/XMLSchema-instance", true);
to:
if(LiquidTechnologies.Runtime.SerializationContext.Default.NamespaceAliases.ContainsPrefix("xs") == false)
LiquidTechnologies.Runtime.SerializationContext.Default.NamespaceAliases.Add("xs", "http://www.w3.org/2001/XMLSchema-instance", true);
However, this is not recommended as you may get duplicate namespace and other clashes with static data.