Reputation: 3
I have a problem running my Liquid-XML Project on production machine. The liquid xml license is ok. I recreated the class lib with liquid xml studio but no changes at the error front.
cmd line gives me these informations:
Ausnahmefehler: System.TypeInitializationException: Der Typeninitialisierer für "myLib.Registration" hat eine Ausnahme verursacht. ---> System.ArgumentException: Ein Element mit dem gleichen Schlüssel wurde bereits hinzugefügt. bei System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) bei myLib.Registration.RegisterLicense() in [PATH]\coding\my.xsd.Output\SourceCodeVBNet\Enumerations.vb:Zeile 53.
Line 53 is the license register code:
LiquidTechnologies.Runtime.Net45.XmlObjectBase.Register("company xyz", "my.xsd","somecharshere")
Any ideas?
Upvotes: 0
Views: 393
Reputation: 301
Translated Error:
Exception Error: System.TypeInitializationException: The type initializer for "myLib.Registration" caused an exception. ---> System.ArgumentException: An element with the same key has already been added. At System.Collections.Generic.Dictionary`2.Insert (TKey key, TValue value, Boolean add) at myLib.Registration.RegisterLicense () in [PATH] \ coding \ my.xsd.Output \ SourceCodeVBNet \ Enumerations.vb: Line 53.
This issue is caused by multiple items getting added to the Default NamespaceAliases Dictionary, e.g. the following would cause this exception as the prefix "abc" is added twice:
LiquidTechnologies.Runtime.Net45.XmlSerializationContext.Default.NamespaceAliases.Add("abc", "http://myurl");
LiquidTechnologies.Runtime.Net45.XmlSerializationContext.Default.NamespaceAliases.Add("abc", "http://myotherurl");
Typically, this issue is seen when two or more Liquid XML Data Binder generated libraries are referenced from your client project. The Default context is static, so adding the same key to XmlSerializationContext.Default.NamespaceAliases will throw an exception, even if they are added in different libraries.
This is covered in the following Knowledge Base Article:
Upvotes: 1