接收错误“找不到类型或命名空间名称‘LayoutsPageBase’" [英] Receiving error of "The type or namespace name 'LayoutsPageBase' could not be found"
问题描述
为了让您全面了解,我正在尝试在 SharePoint 中创建自定义功能区.为此,我正在关注这个 教程.我创建了所需的功能,并能够使用简单的 JavaScript 警报部署和测试它.现在我试图通过点击功能区按钮调用 ASPX 页面.
为此,我在我的项目中创建了一个应用程序页面.但是在 ASP.NET 页面的代码隐藏文件中,我收到以下错误:
找不到类型或命名空间名称LayoutsPageBase"(您是否缺少 using 指令或程序集引用?)C:\Users\Administrator\Documents\Visual Studio 2012\Projects\CustomRibbonButton\CustomRibbonButton\Layouts\CustomRibbonButton\ApplicationPage1.aspx.cs
我已经导入(我希望这就是你在 C# 中所说的)Microsoft.SharePoint.WebControls
和声明 using Microsoft.SharePoint.WebControls;
从 StackOverflow 上的 this question 我能够确定 LayoutsPageBase
类不可用在沙盒解决方案中(路径为 \UserCode\assemblies
).
所以在我的项目中,我去了 References >Microsoft.SharePoint
,右键单击它以查看其属性.它在属性窗口中的Path
显示为C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.dll
.>
此错误的原因是什么,如何解决?
您可以通过在解决方案资源管理器中右键单击项目并查看属性来检查 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 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?
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
.
这篇关于接收错误“找不到类型或命名空间名称‘LayoutsPageBase’"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!