0

のような要件があり、サイト テンプレートをプログラムで作成する必要があります。プログラムでサイトをテンプレートとして保存しようとすると、以下のエラーが発生します。 「一時ディレクトリにソリューション ファイルを生成中にエラーが発生しました」 . 私はc:\windows\tempディレクトリを完全に制御しています.そして、以下の方法を使用しています:

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

(また)

string solutionFileUrl = SPSolutionExporter.ExportWebToGallery(oWeb,templateName, templateTitle,tmplDesc,SPSolutionExporter.ExportMode.FullReuse,true);

同じ問題に直面しています。

SPContext.Current.Web.SaveAsTemplate(templateName, templateTitle, tmplDesc, true); のようなテンプレートとしてルート Web を保存できます。しかし、サブサイトをテンプレートとして保存する必要があります。

以下は私のULSログダンプです

System.Runtime.InteropServices.COMException: リストが存在しません。選択したページには、存在しないリストが含まれています。別のユーザーによって削除された可能性があります。 Microsoft.SharePoint.WebPartPages.ListViewWebPart.EnsureListAndView(Boolean requireFullBlownViewSchema) の ListViewWebPart.EnsureList() Microsoft.SharePoint.WebPartPages.ListViewWebPart.ShouldSerializeTitle() の Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterListViewWebPart.Write14_ListViewWebPart... ...(文字列 n、文字列 ns、ListViewWebPart o、ブール値 isNullable、
System.Xml.Serialization.TempAssembly.InvokeWriter (XmlMapping マッピング、XmlWriter xmlWriter、オブジェクト o、XmlSerializerNamespaces 名前空間、文字列 encodingStyle、文字列 id) で System.Xml.Serialization.XmlSerializer.S... ....erialize (XmlWriter xmlWriter,オブジェクト o、XmlSerializerNamespaces 名前空間、文字列 encodingStyle、文字列 id) で Microsoft.SharePoint.WebPartPages.WebPart.SerializeXml(XmlWriter ライター、XmlSerializer xmls、ブール値 shouldSerializeAll) で Microsoft.SharePoint.WebPartPages.WebPart.SerializeWebPartXml(ブール値 shouldExcludeSpecialProperties、TextWriter ライター) でMicrosoft.SharePoint.WebPartPages.WebPart.WriteXmlAsUtf8(Boolean shouldExcludeSpecialProperties) Microsoft.SharePoint.WebPartPages.SPWebPartManager.GetWebPartXml(WebPart webPart, Boolean shouldUTF8Encode,Boolean shouldExcludeSpecialProperties, Boolean export) at Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager.ExportWebPart(WebPart webPart, XmlWriter writer) at Microsoft.SharePoint.SPSolutionExporter... ....GetFilesInFolderTree(SPFolder フォルダー, SortedList2 filesInFolder, List1 webViews) Microsoft.SharePoint.SPSolutionExporter.GetFilesInFolderTree(SPFolder フォルダー、SortedList 2 filesInFolder, List) に 1 webViews) Microsoft.SharePoint.SPSolutionExporter.GetFilesInFolderTree(SPFolder フォルダー、SortedList)2 filesInFolder, List1 webViews) で Microsoft.SharePoint.SPSolutionExporter.GetFilesInWeb(String workflowTemplateName) で Microsoft.SharePoint.SPSolutionExporter.GenerateSolutionFiles() で Microsoft.SharePoint.SPSolutionExporter.ExportWebAsSolution() で Microsoft.SharePoint.SPSolutionExporter.ExportWebToGallery(SPWeb web, String solutionFileName, Microsoft.SharePoint.SPWeb.SaveAsTemplate(文字列 strTemplateName、文字列 strTemplateTitle、文字列 strTemplateDescription 、Boolean fSaveData) (TemplateIssueProject.ProjectTemplate.<>c__DisplayClass9.b__6()、Microsoft.SharePoint.SPSecurity.<>c__DisplayClass5)。Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) の b__3() (文字列 webName、文字列 templateName、文字列 template... ...タイトル、文字列 tmplDesc)文字列 templateName、文字列テンプレート... ...タイトル、文字列 tmplDesc)文字列 templateName、文字列テンプレート... ...タイトル、文字列 tmplDesc)
TemplateIssueProject.ProjectTemplate.SiteCreation (文字列 siteName) で TemplateIssueProject.TemplateIssewebpart.TemplateIssewebpart.btnSubmit_Click (オブジェクトの送信者、EventArgs e) で System.Web.UI.WebControls.Button.RaisePostBackEvent (文字列 eventArgument) で System.Web.UI.Page。 ProcessRequestMain (ブール値 includeStagesBeforeAsyncPoint、ブール値 includeStagesAfterAsyncPoint)
で System.Web.UI.Page.ProcessRequest (ブール値 includeStagesBeforeAsyncPoint、ブール値 includeStagesAfterAsyncPoint)
System.Web.UI.Page.ProcessRequest() で System.Web.UI.Page.ProcessRequest(HttpContext コンテキスト) で ASP.WKPSTD_ASPX__1961116010.ProcessRequest(HttpContext コンテキスト) で System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication .IExecut... ...ionStep.Execute() System.Web.HttpApplication.ExecuteStep で (IExecutionStep step, Boolean& completedSynchronously) System.Web.HttpApplication.PipelineStepManager.ResumeSteps で (例外エラー) System.Web.HttpApplication.BeginProcessRequestNotification でSystem.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext,IntPtr moduleData、Int32 フラグ) System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer、IntPtr nativeRequestContext、IntPtr moduleData、Int32 フラグ) で System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletio... ...n(IntPtr pHandler、 RequestNotificationStatus& notificationStatus)
System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion (IntPtr pHandler、RequestNotificationStatus& notificationStatus) で System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper (IntPtr rootedObjectsPointer、IntPtr nativeRequestContext、IntPtr moduleData、Int32 フラグ) で System.Web.Hosting.PipelineRuntime.ProcessRequestNotification (IntPtr rootedObjectsPointer、IntPtr nativeRequestContext、IntPtr moduleData、Int32 フラグ)

System.NullReferenceException: オブジェクト参照がオブジェクトのインスタンスに設定されていません。Microsoft.SharePoint.SPSolutionExporter.GetFilesInFolderTree (SPFolder フォルダー、SortedList 2 filesInFolder, List1 webViews) で Microsoft.SharePoint.SPSolutionExporter.GetFilesInFolderTree (SPFolder フォルダー、SortedList 2 filesInFolder, List1 webViews) で Microsoft.SharePoint.SPSolutionExporter.GetFilesInFolderTree (SPFolder フォルダー、SortedList 2 filesInFolder, List1 webViews) Microsoft で.SharePoint.SPSolutionExporter.GetFilesInWeb(String workflowTemplateName) (Microsoft.SharePoint.SPSolutionExporter.GenerateSolutionFiles() で、Microsoft.SharePoint.SPSolutionExporter.ExportWebAsSolution() で)

/SitePages/MyTaskPage.aspx にアクセスするときのアプリケーション エラー、エラー = 一時ディレクトリにソリューション ファイルを生成中にエラーが発生しました。TemplateIssueProject.ProjectTemplate.SiteCreation (文字列 siteName)
で TemplateIssueProject.TemplateIssewebpart.TemplateIssewebpart.btnSubmit_Click (オブジェクトの送信者、EventArgs e) で System.Web.UI.WebControls.Button.RaisePostBackEvent (文字列 eventArgument) で System.Web.UI.Page。 ProcessRequestMain(ブール値 includeStagesBeforeAsyncPoint、ブール値 includeStagesAfterAsyncPoint)

System.InvalidOperationException: 一時ディレクトリにソリューション ファイルを生成中にエラーが発生しました。TemplateIssueProject.ProjectTemplate.SiteCreation (文字列 siteName)
で TemplateIssueProject.TemplateIssewebpart.TemplateIssewebpart.btnSubmit_Click (オブジェクトの送信者、EventArgs e) で System.Web.UI.WebControls.Button.RaisePostBackEvent (文字列 eventArgument) で System.Web.UI.Page。 ProcessRequestMain(ブール値 includeStagesBeforeAsyncPoint、ブール値 includeStagesAfterAsyncPoint)

提案/提案をしてください。

よろしく、

4

2 に答える 2

0

機能を介してフィールドを追加し、フィールドに Overwrite="FALSE" が含まれている場合、サイトのエクスポートは失敗します。デフォルトは FALSE であるため、TRUE に設定する必要がある場合にのみ上書きを使用してください。

これは SharePoint のバグのようです。

この属性が ULS ログに記載されている場合があります。

于 2014-07-14T19:55:55.280 に答える
0

以下のコードは、サイトをテンプレート (ルート レベル/サブサイト) として保存するために使用されます。

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();

よろしく、マヘシュ http://sharepointchampion.blogspot.in/2014/05/save-site-as-template-programatically.html

于 2014-05-04T11:42:47.290 に答える