【问题标题】:Infopath FileQueryConnection.Execute(XpathNavigator) throws System.Net.WebException: Attempted to read or write protected memoryInfopath FileQueryConnection.Execute(XpathNavigator) throws System.Net.WebException: Attempted to read or write protected memory
【发布时间】:2011-04-19 06:11:25
【问题描述】:

我在 2007 年启用浏览器的 infopath 表单的字段更改事件中有此代码 -

 try
        {

        XmlDocument outputFile = new XmlDocument();
FileQueryConnection con = (FileQueryConnection)DataConnections["connection1"];
con.FileLocation = @"http://server_name/_vti_bin/owssvr.dll"
         + "?Cmd=Display&List={List_ID}"
         + "&XMLDATA=TRUE&View={View_ID}&Query=*"
            + "&FilterField1=Country_x0020_Name&FilterValue1="
            + country.Replace("&","%26");
            outputFile.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\" ?><outputRoot></outputRoot>");

            XmlNamespaceManager outputFileNamespaceManager = new XmlNamespaceManager(outputFile.NameTable);

            // XmlDocument output file created above.
            XPathNavigator outputFileNavigator = outputFile.CreateNavigator();
            XPathNavigator outputRootNavigator = 
            outputFileNavigator.SelectSingleNode("/outputRoot",outputFileNamespaceManager);
            con.Execute(outputRootNavigator);
            File.AppendAllText(@"E:\log.txt", outputRootNavigator.ToString());
        }
        catch (Exception exp)
        {
            File.AppendAllText(@"E:\exp.txt", exp.ToString());
        }

我得到了这个异常 -

System.Net.WebException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.at Microsoft.Office.InfoPath.Internal.MomExceptionHelper.ExecuteDataConnectionAction(OMCall d) at Microsoft.Office.InfoPath.Internal.FileQueryConnectionHost.Execute(XPathNavigator output) at cascadeTemplate.FormCode.field1_Changed(Object sender, XmlEventArgs e)

为什么会抛出这样的异常?我的代码中是否缺少某些内容?

感谢您的帮助!

【问题讨论】:

    标签: c# asp.net xml sharepoint infopath


    【解决方案1】:

    con.Execute(outputRootNavigator); 在写入日志文件之前,您应该在此处关闭连接“con”。 File.AppendAllText(@"E:\log.txt", outputRootNavigator.ToString());

    【讨论】:

      【解决方案2】:

      它很可能是由 FileQueryConnection 引起的。由于从未使用过 con 变量,因此删除以下行:

           FileQueryConnection con = (FileQueryConnection)DataConnections["connection1"];
           con.FileLocation = ...
      

      【讨论】:

      • 对不起!我不明白!如果我删除这些行,我将无法使用将内容写入 xml 文档的 con.Execute() 方法。
      猜你喜欢
      • 2021-05-08
      • 1970-01-01
      • 2016-01-08
      • 1970-01-01
      • 2013-06-16
      • 1970-01-01
      • 1970-01-01
      • 2022-12-26
      • 1970-01-01
      相关资源
      最近更新 更多