收到“无法找到类型或命名空间名称’LayoutsPageBase’的错误”

为了给您提供完整的视角,我尝试在SharePoint中创建自定义function区。 为此,我正在学习本教程 。 我创建了所需的function,并能够使用简单的JavaScript警报进行部署和测试。 现在我试图点击function区按钮调用ASPX页面。

为此,我在我的项目中创建了一个应用程序页面。 但是在ASP.NET页面的代码隐藏文件中,我收到以下错误:

The type or namespace name 'LayoutsPageBase' could not be found (are you missing a using directive or an assembly reference?) C:\Users\Administrator\Documents\Visual Studio 2012\Projects\CustomRibbonButton\CustomRibbonButton\Layouts\CustomRibbonButton\ApplicationPage1.aspx.cs 

我已导入(我希望你在C#中称之为) Microsoft.SharePoint.WebControls with statement using Microsoft.SharePoint.WebControls;

从StackOverflow上的这个问题我可以看出LayoutsPageBase类在沙盒解决方案中不可用(路径为\UserCode\assemblies )。

所以在我的项目中,我去了References > Microsoft.SharePoint ,右键单击它以查看其属性。 其“属性中的Path窗口显示为C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.dll

这个错误的原因是什么?如何解决?

您可以通过右键单击解决方案资源管理器中的项目并查看属性来检查SharePoint项目是否为沙盒。

有一个名为Sandboxed Solution的真/假属性。