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):
Unhandled exception LtXmlLib21::CLtInvalidParamException
Message=m_message = An entry for the alias [xs] has already been registered.
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:
LtXmlLib21::CSerializationContext CEnumerations::myLibraryAContext;
...
// add default namespace
namespacesCEnumerations::myLibraryAContext.GetNamespaceAliases().Add(_T("xs"), _T("http://www.w3.org/2001/XMLSchema-instance"), true);
// add your own namespaces
CEnumerations::myLibraryAContext.GetNamespaceAliases().Add(_T("..."), _T("..."), 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:
LtXmlLib21::CSerializationContext::GetDefaultContext().GetNamespaceAliases().Add(_T("xs"), _T("http://www.w3.org/2001/XMLSchema-instance"), true);
to:
if(LtXmlLib21::CSerializationContext::GetDefaultContext().GetNamespaceAliases().DoesAliasExist(_T("xs")) == false)
LtXmlLib21::CSerializationContext::GetDefaultContext().GetNamespaceAliases().Add(_T("xs"), _T("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.