收到"无法找到类型或命名空间名称'LayoutsPageBase'的错误"

Nav*_*een 3 c# asp.net sharepoint visual-studio-2012 sharepoint-2013

为了给您提供全部视角,我尝试在SharePoint中创建自定义功能区.为此,我正在学习本教程.我创建了所需的功能,并能够使用简单的JavaScript警报进行部署和测试.现在我试图点击功能区按钮调用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
Run Code Online (Sandbox Code Playgroud)

Microsoft.SharePoint.WebControls用语句导入(我希望你在C#中称之为它)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.

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

Rob*_*obH 7

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

有一个真/假属性叫Sandboxed Solution.