I want to deserialize an xmla file which has a database object in it to the correct object representation of it. (I don’t know if it is supposed to be a Database). So, I do the following:
Database db = new Database();
XmlTextReader xmlread = new XmlTextReader("input.xmla");
Microsoft.AnalysisServices.Utils.Deserialize(xmlread, db);
xmlread.Close();
But I get the following error:
Unhandled Exception: Microsoft.AnalysisServices.XmlSerializationException: Unexpected root 'Create' (namespace 'http://schemas.microsoft.com/analysisservices/2003/engine') when trying to read 'Microsoft.AnalysisServices.Database'.
at Microsoft.AnalysisServices.DesignXmlReader.ReadRoot (System.Type type) [0x00000] in <filename unknown>:0
at Microsoft.AnalysisServices.DesignXmlReader.DeserializeComponent (IDesignerSerializationManager manager, System.Xml.XmlReader reader, System.Type root) [0x00000] in <filename unknown>:0
at Microsoft.AnalysisServices.JaXmlSerializer.DeserializeComponent (IDesignerSerializationManager manager, System.Xml.XmlReader reader, System.Type root) [0x00000] in <filename unknown>:0
at Microsoft.AnalysisServices.Utils.Deserialize (System.Xml.XmlReader xmlReader, Microsoft.AnalysisServices.MajorObject obj) [0x00000] in <filename unknown>:0
The input.xmla file looks like this:
<Create xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
<ObjectDefinition>
<Database xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ddl2="http://schemas.microsoft.com/analysisservices/2003/engine/2" xmlns:ddl2_2="http://schemas.microsoft.com/analysisservices/2003/engine/2/2" xmlns:ddl100_100="http://schemas.microsoft.com/analysisservices/2008/engine/100/100" xmlns:ddl200="http://schemas.microsoft.com/analysisservices/2010/engine/200" xmlns:ddl200_200="http://schemas.microsoft.com/analysisservices/2010/engine/200/200">
<ID>100</ID>
<Name>Deserialized</Name>
<Description>Deserialized Description</Description>
</Database>
</ObjectDefinition>
</Create>
I couldn’t find a good example for it. Any help would be greatly appreciated.
The problem is, that you are trying to deserialize a xmla-document containing a “CREATE”-command, and not only the serialized database-object. If you had a xml-reader sitting only on the database-node, it should work!