调用GetListItems(...) Web服务方法时,我最终遇到异常。自定义InfoPath表单时,我正在使用Visual Studio Tools for Applications。这是在创建.NET 2.0代码。

我坐在主机上,并查询SharePoint WFE。在我从InfoPath 2010和InfoPath 2007切换之前,它一直运行良好。在切换到InfoPath 2007之后,重新安装了VSTA,这可能是导致som时髦的问题。有人知道如何解决这个问题吗?

我已经修改了.net 2.0的本地web.config和.net框架配置2.0,以完全信任应用程序的强名称。

有小费吗?

完整的堆栈跟踪:

System.Security.SecurityException was unhandled by user code
  Message="Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
  Source="mscorlib"
  StackTrace:
       at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
       at System.Security.CodeAccessPermission.Demand()
       at System.Net.HttpWebRequest..ctor(Uri uri, ServicePoint servicePoint)
       at System.Net.HttpRequestCreator.Create(Uri Uri)
       at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase)
       at System.Net.WebRequest.Create(Uri requestUri)
       at System.Web.Services.Protocols.WebClientProtocol.GetWebRequest(Uri uri)
       at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebRequest(Uri uri)
       at System.Web.Services.Protocols.SoapHttpClientProtocol.GetWebRequest(Uri uri)
       at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
       at Sjekkliste2.SharePointLists.Lists.GetListItems(String listName, String viewName, XmlNode query, XmlNode viewFields, String rowLimit, XmlNode queryOptions, String webID)
       at Sjekkliste2.FormCode.EnhetExists(String lokasjon)
       at Sjekkliste2.FormCode.ddLokasjon_Validating(Object sender, XmlValidatingEventArgs e)
       at Microsoft.Office.InfoPath.Internal.XmlEventHost.GenericProxy(Object genericDelegate, DataDOMEvent dataDOMEvent, InfoPathEvents type)
       at Microsoft.Office.InfoPath.Internal.XmlEventHost.ValidatingProxy(DataDOMEvent dataDOMEvent)
       at Microsoft.Office.Interop.InfoPath.SemiTrust._DataDOMEventSink_SinkHelper.OnValidate(DataDOMEvent pDataDOMEvent)

最佳答案

根据堆栈跟踪,您的应用程序在运行代码时没有WebPermission。这可能是由于您的代码未在您的宿主站点上设置为完全信任(是的,这可能是由于新安装)引起的。

在主机上检查代码的安全设置-您的代码现在无法创建WebRequest。

07-25 21:22