[英]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.