Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sharepoint 以编程方式将站点另存为模板-在临时目录中生成解决方案文件时出错_Sharepoint_Sharepoint 2013_Sitetemplate - Fatal编程技术网

Sharepoint 以编程方式将站点另存为模板-在临时目录中生成解决方案文件时出错

Sharepoint 以编程方式将站点另存为模板-在临时目录中生成解决方案文件时出错,sharepoint,sharepoint-2013,sitetemplate,Sharepoint,Sharepoint 2013,Sitetemplate,我有这样一个要求,我需要创建网站模板编程。 当我试图以编程方式将站点保存为模板时,我得到了以下错误。 “在临时目录中生成解决方案文件时出错”。 我已经完全控制了c:\windows\temp目录。我正在使用以下方法: oWeb.SaveAsTemplate(templateName, templateTitle, tmplDesc, true); (或) 面对同样的问题 我能够像SPContext.Current.web.saveaTemplate(templateName、templateT

我有这样一个要求,我需要创建网站模板编程。 当我试图以编程方式将站点保存为模板时,我得到了以下错误。 “在临时目录中生成解决方案文件时出错”。 我已经完全控制了c:\windows\temp目录。我正在使用以下方法:

oWeb.SaveAsTemplate(templateName, templateTitle, tmplDesc, true);
(或)

面对同样的问题

我能够像SPContext.Current.web.saveaTemplate(templateName、templateTitle、tmplDesc、true)一样将根web保存为模板; 但我需要保存子网站作为模板

下面是我的ULS日志转储

System.Runtime.InteropServices.COMException:列表不存在。这个 您选择的页面包含不存在的列表。可能有 已被其他人删除 user.0x81020026, StackTrace:在 Microsoft.SharePoint.SPListCollection.EnsureListData(Guid webId, 字符串strListName)位于 Microsoft.SharePoint.SPListCollection.ItemByInternalName(Guid webId, 字符串列表名)位于 Microsoft.SharePoint.WebPartPages.ListViewWebPart.EnsureList()位于 Microsoft.SharePoint.WebPartPages.ListViewWebPart.View(布尔值 requireFullBlownViewSchema)在 Microsoft.SharePoint.WebPartPages.ListViewWebPart.ShouldSerializeTitle() 在 Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterListViewWebPart.Write14_ListViewWebPart。。。 …(字符串n,字符串ns,ListViewWebPart o,布尔值为空, 布尔类型)在 Microsoft.Xml.Serialization.GenerateAssembly.XmlSerializationWriterListViewWebPart.Write15_Web Part(对象 o) 在System.RuntimeMethodHandle.InvokeMethod(对象目标, 对象[]参数、签名sig、布尔构造函数)位于 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(对象obj, 对象[]参数,对象[]参数)位于 System.Reflection.RuntimeMethodInfo.Invoke(对象obj,BindingFlags invokeAttr,Binder Binder,对象[]参数,CultureInfo区域性)
位于System.Xml.Serialization.TempAssembly.InvokeWriter(XmlMapping 映射,XmlWriter XmlWriter,对象o,XmlSerializerNamespaces 名称空间、字符串编码样式、字符串id) System.Xml.Serialization.XmlSerializer.S。。。埃里泽(XmlWriter) xmlWriter,对象o,XmlSerializerNamespaces名称空间,字符串 编码样式,字符串id)位于 Microsoft.SharePoint.WebPartPages.WebPart.SerializeXml(XmlWriter 编写器、XmlSerializer(xmls、Boolean应全部序列化)位于 Microsoft.SharePoint.WebPartPages.WebPart.SerializeWebPartXml(布尔值 应排除特殊属性,TextWriter)位于 Microsoft.SharePoint.WebPartPages.WebPart.WriteXmlAsUtf8(布尔值 应排除特殊属性)在 Microsoft.SharePoint.WebPartPages.SPWebPartManager.GetWebPartXml(WebPart Web部件,布尔值应为UTF8Encode,布尔值 应排除特殊属性,布尔值导出)位于 Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager.ExportWebPart(Web部件 Web部件,XmlWriter)位于 Microsoft.SharePoint.SPSolutionExporter。。。 …GetFileInfolderTree(SPFolder文件夹,SortedList
2文件信息文件夹,
列表
1网络视图)位于 Microsoft.SharePoint.SPSolutionExporter.GetFilesInFolderTree(SPFolder 文件夹,分类列表
2文件信息文件夹,列表
1网络视图)位于
Microsoft.SharePoint.SPSolutionExporter.GetFilesInFolderTree(SPFolder
文件夹,分类列表
2文件信息文件夹,列表
1网络视图)位于
Microsoft.SharePoint.SPSolutionExporter.GetFilesInWeb(字符串
workflowTemplateName)位于
Microsoft.SharePoint.SPSolutionExporter.GenerateSolutionFiles()位于
Microsoft.SharePoint.SPSolutionExporter.ExportWebAsSolution()位于
Microsoft.SharePoint.SPSolutionExporter.ExportWebToGallery(SPWeb,
字符串解决方案文件名、字符串标题、字符串描述、导出模式
exportMode、布尔includeContent、字符串workflowTemplateName、,
字符串destina…tionListUrl,操作'1 solutionPostProcessor,
布尔激活解)在
Microsoft.SharePoint.SPWeb.SaveAsTemplate(字符串strTemplateName,
字符串strTemplateTitle,字符串strTemplateDescription,布尔值
fSaveData)在
TemplateIssueProject.ProjectTemplate.c__DisplayClass9.b__u6()
在
Microsoft.SharePoint.SPSecurity.c__DisplayClass5.b__3()
在
Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated
安全代码)在
Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback
安全代码,对象参数)位于
Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(Code或Unelevated
安全代码)在
TemplateIssueProject.ProjectTemplate.SaveTemplate(字符串webName,
字符串模板名称,字符串模板……标题,字符串tmplDesc)
在TemplateIssueProject.ProjectTemplate.SiteCreation处(字符串siteName) 在 TemplateIssueProject.TemplateIssewebpart.TemplateIssewebpart.btnSubmit\u单击(对象 发件人,事件参数(e)位于 System.Web.UI.WebControl.Button.RaisePostBackEvent(字符串 System.Web.UI.Page.ProcessRequestMain中的eventArgument(布尔值) IncludeStages在区域同步点之前,布尔值IncludeStages在区域同步点之后)
在System.Web.UI.Page.ProcessRequest中(布尔值 IncludeStages在区域同步点之前,布尔值IncludeStages在区域同步点之后)
在System.Web.UI.Page.ProcessRequest()中 System.Web.UI.Page.ProcessRequest(HttpContext上下文)位于 ASP.WKPSTD_ASPX_u1961116010.ProcessRequest(HttpContext上下文)位于 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecut。。。 …onstep.Execute()位于 System.Web.HttpApplication.ExecuteStep(IExecutionStep步骤,布尔值& 同步完成)在 System.Web.HttpApplication.PipelineStepManager.ResumeSteps(异常 错误)在 System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext 上下文,异步回调(cb)位于 System.Web.HttpRuntime.ProcessRequestNotificat
string solutionFileUrl = SPSolutionExporter.ExportWebToGallery(oWeb,templateName, templateTitle,tmplDesc,SPSolutionExporter.ExportMode.FullReuse,true);
using System.Management;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
Add Reference to your solution from the below path.

Reference Path: C:\Windows\winsxs\msil_system.management.automation_31bf3856ad364e35_7.1.7601.18071_none_a682d4c5c360dacf\System.Management.Automation.dll

RunspaceInvoke oRunSpaceInvoke = new RunspaceInvoke();
                    FullWebUrl = SPContext.Current.Site.Url + "/" + objTemplate.strWebName;
                    strScriptToSaveTemp = @"Add-PSSnapin Microsoft.SharePoint.PowerShell ; Set-ExecutionPolicy -ExecutionPolicy RemoteSigned ;" +
                                    "$oWeb = Get-SPWeb " + FullWebUrl + " ; $oWeb.SaveAsTemplate('" + objTemplate.strTemplateTitle + "','" + objTemplate.strTemplateName + "','" + objTemplate.strTemplateDesc + "',1) \n";
oRunSpaceInvoke.Invoke(strScriptToSaveTemp).ToString();