0

我想将其中包含数据库对象的 xmla 文件反序列化为正确的对象表示形式。(我不知道它是否应该是一个数据库)。因此,我执行以下操作:

Database db = new Database();
XmlTextReader xmlread = new XmlTextReader("input.xmla");
Microsoft.AnalysisServices.Utils.Deserialize(xmlread, db);
xmlread.Close();

但我收到以下错误:

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 

input.xmla 文件如下所示:

<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>

我找不到一个很好的例子。任何帮助将不胜感激。

4

1 回答 1

2

问题是,您试图反序列化包含“CREATE”命令的 xmla 文档,而不仅仅是序列化的数据库对象。如果您有一个仅位于数据库节点上的 xml-reader,它应该可以工作!

于 2012-11-22T21:22:15.843 回答