System.Security.SecurityException请求类型为';Microsoft.SharePoint.Security.SharePointPermission
我创建了一个启用浏览器的表单,它有两个字段。我想使用SharePoint对象模型 我已将SharePoint dll添加到项目中,还包括使用Microsoft.SharePoint语句System.Security.SecurityException请求类型为';Microsoft.SharePoint.Security.SharePointPermission,sharepoint,sharepoint-2007,infopath,infopath-2007,Sharepoint,Sharepoint 2007,Infopath,Infopath 2007,我创建了一个启用浏览器的表单,它有两个字段。我想使用SharePoint对象模型 我已将SharePoint dll添加到项目中,还包括使用Microsoft.SharePoint语句 using Microsoft.Office.InfoPath; using System; using System.Xml; using System.Xml.XPath; using Microsoft.SharePoint; namespace test1 { public partial
using Microsoft.Office.InfoPath;
using System;
using System.Xml;
using System.Xml.XPath;
using Microsoft.SharePoint;
namespace test1
{
public partial class FormCode
{
public void InternalStartup()
{
((ButtonEvent)EventManager.ControlEvents["CTRL2_5"]).Clicked += new ClickedEventHandler(CTRL2_5_Clicked);
}
public void CTRL2_5_Clicked(object sender, ClickedEventArgs e)
{
string url = "http://site";
using (SPSite site = new SPSite(url))
{
using (SPWeb web = site.OpenWeb())
{
XPathNavigator nav = MainDataSource.CreateNavigator();
nav.SelectSingleNode("/my:myFields/my:field1", NamespaceManager).SetValue(web.Title.to nav.SelectSingleNode("/my:myFields/my:field2",NamespaceManager).Value.ToString());
}
}
// Write your code here.
}
}
}
`
当我点击按钮时,我得到以下错误
System.Security.SecurityException
Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed.
at test1.FormCode.CTRL2_5_Clicked(Object sender, ClickedEventArgs e)
at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)
在表单选项->安全和信任->完全信任下
Please can anyone suggest if I need to do anything else.
我在代码中也面临同样的问题。我已经做了以下工作,问题已经解决。请尝试下面的,让我知道它是否解决了这个问题 文件>信息>设计检查器>打开“设计检查器”窗口。在该对话框中,单击更改设置>安全和信任>选择完全信任选项