问题
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 StackOverflow 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?
回答1:
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.
来源:https://stackoverflow.com/questions/20741291/receiving-error-of-the-type-or-namespace-name-layoutspagebase-could-not-be-fo