且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

接收错误“找不到类型或命名空间名称‘LayoutsPageBase’"

更新时间:2023-02-20 10:55:58

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

有一个 true/false 属性叫做 Sandboxed Solution.

To give you entire perspective, I am trying to create a custom ribbon in SharePoint. For that I am following this tutorial. I created the required feature and was able to deploy and test it with simple JavaScript alert. Now I am trying to call an ASPX page on click of ribbon button.

For that I created an Application Page in my project. But in the code behind file of ASP.NET page I get the following error:

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

I have imported (I hope thats what you call it in C#) Microsoft.SharePoint.WebControls with statement using Microsoft.SharePoint.WebControls;

From this question on *** I was able to figure that LayoutsPageBase class is not available in sandbox solutions (with path as \UserCode\assemblies).

So in my project I went to References > Microsoft.SharePoint, right-clicked on it to view its Properties. Its Path in Properties window is shown as C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.dll.

What can be the reason for this error and how can it be solved?

You can check whether or not a SharePoint project is Sandboxed by right clicking the project in Solution Explorer and viewing the properies.

There is a true/false property called Sandboxed Solution.