从 InfoPath 表单 (VSTA) 调用 SharePoint Web 服务 (_vti_bin/Lists.asmx) 时出现 System.Security.SecurityException

发布于 2024-12-04 02:40:19 字数 2168 浏览 2 评论 0原文

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

我坐在我的主机上,正在查询 SharePoint WFE。在我从 InfoPath 2010 和 InfoPath 2007 切换之前,此功能一直运行良好。在我切换到 InfoPath 2007 后,VSTA 被重新安装,可能导致一些奇怪的问题。有人知道如何解决这个问题吗?

我已修改了 .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)

I have ended up with an exception when calling the GetListItems(...) web service method. I am using Visual Studio Tools for Applications as I am customizing an InfoPath form. This is creating .NET 2.0 code.

I am sitting on my host computer, and querying the SharePoint WFE. This has been working nicely before I switched from InfoPath 2010 and InfoPath 2007. After I switched over to InfoPath 2007, VSTA was reinstalled an probably caused som funky issues. Anyone got an idea on how to solve this?

I have modified both my local web.config for .net 2.0, and my .net framework configuration 2.0 to allow full trust on the strong name of my application.

Any tips?

The full stacktrace:

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

奶气 2024-12-11 02:40:19

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

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

According to the stack trace, your application doesn't have WebPermission while running the code. This can be caused because your code isn't set as full trust at your host site (and yes, this could be caused by new install).

Check the security settings for your code at the host - your code can't create WebRequests now.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文