VSTO Visio加载项解决方案XmlElement错误

我正在为Visio开发VSTO加载项,并且需要使用Document.SolutionXmlElement属性保存文档属性。以下代码演示了处理程序,该处理程序在保存之前将对象的XML序列化。基于阅读,我将C#类实例包装在具有名称属性的SolutionXml包装器中,该属性设置为封闭的序列化类实例的元素名称:

margin: 30px auto;

serializzed XML如下:

        private void Document_Saved(Visio.Document document)
        {
        IDictionary<string,ModelGenmVCModel> documentModel = GetRibbon().documentModel;
        if (documentModel.TryGetvalue(document.Name,out ModelGenmVCModel modelGenmVCModel))
        {
            try
            {
                string serializedmodel = new SolutionXml(modelGenmVCModel,ModelGenVisioAddIn.Properties.Resources.SolutionXmlElementName).Serialize();
                LOGGER.Debug(String.Format("Saving model gen properties:\n{0}",serializedmodel));
                document.SolutionXMLElement[ModelGenVisioAddIn.Properties.Resources.SolutionXmlElementName] = serializedmodel;
            } catch ( Exception e)
            {
                LOGGER.Error(String.Format("Serialization error {0}\n{1}",e.Message,e.StackTrace));
            }
        }
    }

但是,我抛出了“无效参数”异常。任何帮助将不胜感激。

感谢和问候 安德鲁

liuqifeng052 回答:VSTO Visio加载项解决方案XmlElement错误

我这里有一个代码示例,演示了如何管理SolutionXmlElement。您可以检查一下(如果它适合您)。它定义了一个简单的类来保存/加载设置:

https://unmanagedvisio.com/using-solutionxml-with-c/

我相信,问题可能是,您实际上需要在其中放置XML,而不是序列化的字符串。但是,如果不看完整的例子就很难说。

本文链接:https://www.f2er.com/2603445.html

大家都在问