不将第一个项目部署到SharePoint。

时间:2021-02-05 20:23:37

I have Visual Studio 2010 and SharePoint 2010. I created my first project with page MyFirstPage.aspx. When I'm deploing this project I have next error:

我有Visual Studio 2010和SharePoint 2010。我用mypage firstpage .aspx创建了我的第一个项目。当我检查这个项目时,我有下一个错误:

The deployment type "TemplateFile" of file "MyFirstPage.aspx" in Project Item "Layouts" is not compatible with a Package in a Sandboxed Solution

文件“MyFirstPage”的部署类型“TemplateFile”。在项目项目项目“布局”中,aspx“与沙箱解决方案中的包不兼容

So, how this fixed?

所以,如何固定?

MyFirstPage.aspx has next code:

MyFirstPage。aspx下代码:

    <%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
    <%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
    <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
    <%@ Import Namespace="Microsoft.SharePoint" %>
    <%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MyFirstPage.aspx.cs" Inherits="SharePointProject1.Layouts.SharePointProject1.MyFirstPage" DynamicMasterPageFile="~masterurl/default.master" %>

    <asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">

    </asp:Content>

    <asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
        <h2>My Farm</h2>
        <asp:TreeView ID="farmHierarchyViewer" runat="server"
        ShowLines="true" EnableViewState="true">
        </asp:TreeView> 
    </asp:Content>

    <asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
    Farm Hierarchy and Properties 
    </asp:Content>

    <asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server" >
    My Farm Hierarchy 
    </asp:Content>

MyFirstPage.aspx.cs:

MyFirstPage.aspx.cs:

        using System;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.WebControls;
    using System.Web.UI.WebControls;
    using Microsoft.SharePoint.Administration; 

    namespace SharePointProject1.Layouts.SharePointProject1
    {
        public partial class MyFirstPage : LayoutsPageBase
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                SPFarm thisFarm = SPFarm.Local;
                TreeNode node;
                farmHierarchyViewer.Nodes.Clear();
                foreach (SPService svc in thisFarm.Services)
                {
                node = new TreeNode();
                node.Text = "Farm Service (Type=" + svc.TypeName + "; Status="
                + svc.Status + ")";
                farmHierarchyViewer.Nodes.Add(node);
                TreeNode svcNode = node;
                if (svc is SPWebService)
                {
                SPWebService webSvc = (SPWebService)svc;
                foreach (SPWebApplication webApp in webSvc.WebApplications)
                {
                node = new TreeNode();
                node.Text = webApp.DisplayName;
                svcNode.ChildNodes.Add(node);
                TreeNode webAppNode = node;
                if (!webApp.IsAdministrationWebApplication)
                {
                foreach (SPSite site in webApp.Sites)
                {
                site.CatchAccessDeniedException = false;
                try
                {
                node = new TreeNode();
                node.Text = site.Url;
                webAppNode.ChildNodes.Add(node);
                TreeNode siteNode = node;
                node = new TreeNode(site.RootWeb.Title, null, null,
                site.RootWeb.Url +
                "/_layouts/lab01/PropertyChanger.aspx?type=web&objectID="
                + site.RootWeb.ID, "_self");
                siteNode.ChildNodes.Add(node);
                TreeNode parentNode = node;
                foreach (SPList list in site.RootWeb.Lists)
                {
                node = new TreeNode(list.Title, null, null,
                site.RootWeb.Url +
                "/_layouts/lab01/PropertyChanger.aspx?type=list&objectID="
                 + list.ID, "_self");
                parentNode.ChildNodes.Add(node);
                }
                foreach (SPWeb childWeb in site.RootWeb.Webs)
                {
                    try
                    {
                        addWebs(childWeb, parentNode);
                    }
                    finally
                    {
                        childWeb.Dispose();
                    }
                }
                site.CatchAccessDeniedException = false;
                }
                finally
                {
                    site.Dispose();
                }
                }
                }
                }
                }
                }
                farmHierarchyViewer.ExpandAll(); 
            }

            void addWebs(SPWeb web, TreeNode parentNode)
            {
                TreeNode node;
                node = new TreeNode(web.Title, null, null, web.Url
                + "/_layouts/lab01/PropertyChanger.aspx?type=web&objectID="
                + web.ID, "_self");
                parentNode.ChildNodes.Add(node);
                parentNode = node;
                foreach (SPList list in web.Lists)
                {
                    node = new TreeNode(list.Title, null, null, web.Url
                    + "/_layouts/lab01/PropertyChanger.aspx?type=list&objectID="
                    + list.ID, "_self");
                    parentNode.ChildNodes.Add(node);
                }
                foreach (SPWeb childWeb in web.Webs)
                {
                    try
                    {
                        addWebs(childWeb, parentNode);
                    }
                    finally
                    {
                        childWeb.Dispose();
                    }
                }
            } 
        }
    }

1 个解决方案

#1


1  

Deploy as farm solution, since if you want to deploy items to the LAYOUTS folder, you need full trust.

部署为farm解决方案,因为如果要将项目部署到LAYOUTS文件夹,需要完全信任。

#1


1  

Deploy as farm solution, since if you want to deploy items to the LAYOUTS folder, you need full trust.

部署为farm解决方案,因为如果要将项目部署到LAYOUTS文件夹,需要完全信任。