c# - Not deploy first project to SharePoint -
i have visual studio 2010 , sharepoint 2010. created first project page myfirstpage.aspx. when i'm deploing project have next error:
the deployment type "templatefile" of file "myfirstpage.aspx" in project item "layouts" not compatible package in sandboxed solution
so, how fixed?
myfirstpage.aspx has next code:
<%@ 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 , properties </asp:content> <asp:content id="pagetitleintitlearea" contentplaceholderid="placeholderpagetitleintitlearea" runat="server" > farm hierarchy </asp:content>
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 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); } { childweb.dispose(); } } site.catchaccessdeniedexception = false; } { 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); } { childweb.dispose(); } } } } }
deploy farm solution, since if want deploy items layouts folder, need full trust.
Comments
Post a Comment