简体   繁体   English

Infopath FileQueryConnection.Execute(XpathNavigator)引发System.Net.WebException:尝试读取或写入受保护的内存

[英]Infopath FileQueryConnection.Execute(XpathNavigator) throws System.Net.WebException: Attempted to read or write protected memory

I have this code inside a field changed event of a browser enabled infopath form 2007 - 我在启用浏览器的infopath表单2007的字段更改事件中包含此代码-

 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());
        }

I get this exception - 我得到这个例外-

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)

Why is there an exception thrown like this? 为什么会引发这样的异常? Am i missing something in my code? 我在代码中缺少什么吗?

Thanks for the help! 谢谢您的帮助!

Its most likely caused by FileQueryConnection. 它最有可能是由FileQueryConnection引起的。 Since the con variable is never used, remove the the following lines: 由于从未使用con变量,因此请删除以下行:

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

con.Execute(outputRootNavigator); con.Execute(outputRootNavigator); You Should close the connection "con" here before writing log file. 写入日志文件之前,应在此处关闭连接“ con”。 File.AppendAllText(@"E:\\log.txt", outputRootNavigator.ToString()); File.AppendAllText(@“ E:\\ log.txt”,outputRootNavigator.ToString());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试在.NET应用程序中读取或写入受保护的内存 - Attempted to read or write protected memory in a .NET application 尝试读取或写入受保护的内存 - Attempted to read or write protected memory 尝试读取或写入受保护的内存 - Attempted to Read or Write protected memory 尝试读取写保护的内存 - Attempted to read write protected memory HttpWebRequest引发System.Net.WebException Section = ResponseStatusLine - HttpWebRequest throws System.Net.WebException Section=ResponseStatusLine System.AccessViolationException:尝试读取或写入受保护的内存 - System.AccessViolationException:Attempted to read or write protected memory System.AccessViolationException。 尝试读取或写入受保护的内存 - System.AccessViolationException. Attempted to read or write into protected memory C和System.AccessViolationException中的allocVector():尝试读取或写入受保护的内存吗? - allocVector() in C and System.AccessViolationException: Attempted to read or write protected memory? 试图读取或写入受保护的内存-Sql Compact和.NEt - Attempted to read or write protected memory-Sql Compact and .NEt C#.NET-HttpWebRequest-System.Net.WebException-尝试过多的自动重定向 - C# .NET - HttpWebRequest - System.Net.WebException - Too many automatic redirections were attempted
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM