![](/img/trans.png)
[英]Infopath FileQueryConnection.Execute(XpathNavigator) throws System.Net.WebException: Attempted to read or write protected memory
[英]Casting Error on FileQueryConnection in Infopath 2013 Code
我一直在使用infopath表单将infopath 2007迁移到infopath 2013.要将数据绑定到DropDownList控件,已经使用了FileQueryConnection。
// Retrieve the data connection bound to the Manager drop-down list box
FileQueryConnection institutionConnection =(FileQueryConnection)DataConnections[ExternalUsersDC];
// returned by the owssvr.dll with a filter on External Users of Institution
institutionConnection.FileLocation = GetFileLocation(currentSite, externalUsersGuid, ExternalUserInstitution, institution);
// Query the data connection to fill the Manager drop-down list box with items
institutionConnection.Execute();
这里ExternalUsersDC是infopath连接文件的名称。 GetFileLocation方法获取列表物理位置,按预期正常工作。
尝试DataConnection到FileQueryConnection时发生转换错误。 错误信息如下;
无法转换“Microsoft.Office.InfoPath.Internal.SharePointListAdapterRWQueryAdapterHost”类型的对象以键入“Microsoft.Office.InfoPath.FileQueryConnection”
我到处寻找原因并失败了。 如果有人有这个问题的经验,请详细说明我的道路。
尝试AS
运营商。 它将尝试转换为适当的类型。如果不能进行强制转换,它将通过返回NULL
优雅地失败。
FileQueryConnection institutionConnection =DataConnections[ExternalUsersDC] as FileQueryConnection;
// returned by the owssvr.dll with a filter on External Users of Institution
institutionConnection.FileLocation = GetFileLocation(currentSite, externalUsersGuid, ExternalUserInstitution, institution);
// Query the data connection to fill the Manager drop-down list box with items
institutionConnection.Execute();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.