我创建了webpart项目,并在microsoft.sharepoint.dll 15.900版本中出错!!!
我的sharepoint服务器是独立服务器,我的webpart项目是支持框。
错误:
Web Part Error: Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust app domain: Could not load type 'Microsoft.SharePoint.WebControls.SPGridView' from assembly 'Microsoft.SharePoint, Version=15.900.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'. Correlation ID: 7e71979d-0624-c00a-0000-09fb3f08ee0e.
代码:
using (var site = SPContext.Current.Site)
{
using (var web = site.OpenWeb())
{
var list = web.Lists["MyList"];
var result = list.Items.Cast<SPListItem>().ToList();
spGridView.DataSource = result;
spGridView.DataBind();
}
}
.ASCX文件:
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="VisualWebPart1.ascx.cs" Inherits="t5.VisualWebPart1.VisualWebPart1" %>
<SharePoint:SPGridView id="spGridView" runat="server" AutoGenerateColumns="false">
<HeaderStyle HorizontalAlign="Left" ForeColor="Navy" Font-Bold="true" />
<Columns>
<SharePoint:SPBoundField DataField="Title" HeaderText="Employee">
<headerstyle HorizontalAlign="Left" />
</SharePoint:SPBoundField>
</Columns>
</SharePoint:SPGridView>
错误:
答案 0 :(得分:0)
您无法在沙盒解决方案中使用SPGridView。尝试使用GridView控件或创建自己的控件并从GridView继承它。