Debugging error: One of more field types not installed properly
Debugging error: One of more field types not installed properly
我试图将文件夹添加到文档库中的自定义文档集。但是,一个或多个字段有些不对,并且以下错误消息没有向我提供可以缩小范围的信息。我正在寻找一种方法来识别和修复库中有问题的字段。
Microsoft.SharePoint.Client.ServerException was unhandled
HResult=-2146233088
Message=One or more field types are not installed properly. Go to the list settings page to delete these fields.
ServerErrorCode=-2130575340
ServerErrorTraceCorrelationId=0e7a749d-70a8-2000-36cf-14f8618874a2
ServerErrorTypeName=Microsoft.SharePoint.SPException
ServerStackTrace=""
Source=Microsoft.SharePoint.Client.Runtime
StackTrace:
at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb)
at Microsoft.SharePoint.Client.ClientRequest.ExecuteQuery()
at Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQuery()
at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
at Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryImplementation(ClientRuntimeContext clientContext, Int32 retryCount, Int32 delay)
at Microsoft.SharePoint.Client.FileFolderExtensions.CreateFolderImplementation(FolderCollection folderCollection, String folderName, Folder parentFolder)
at Microsoft.SharePoint.Client.FileFolderExtensions.CreateFolder(Folder parentFolder, String folderName)
at AddFolderToDocSet.Program.Main(String[] args) in C:\Users\user\Documents\Visual Studio 2015\Projects\PnPCoreTest\AddFolderToDocSet\Program.cs:line 51
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
这是我用来添加利用 PNP-Sites-Core library.
的文件夹的代码
// Get Root Folders collection for
var projLibRootFldrs = prjLib.RootFolder;
ctx.Load(projLibRootFldrs, pf => pf.Folders);
ctx.ExecuteQueryRetry();
// Get the Document Set
Folder f = projLibRootFldrs.EnsureFolder("Test1");
f.CreateFolder("foo"); // Error here
更新:2016 年 4 月 21 日
经过艰苦的分析(错误...尝试,错误,永远重复)我已经将其缩小到 "Document Set Settings" 的 "Shared Columns" 部分的字段似乎当我检查任何其中发生错误。当我取消选中所有字段以便共享 none 时,我可以添加文件夹。
更新:2016 年 4 月 26 日
以下是重现此错误所需的具体步骤。
这是用于创建文件夹的确切控制台程序:
static void Main(string[] args)
{
string pwd = System.Environment.GetEnvironmentVariable("SOME_PWD", EnvironmentVariableTarget.User);
if (string.IsNullOrEmpty(pwd))
{
System.Console.Write("MSOPWD user environment variable empty, cannot continue. Press any key to end.");
System.Console.ReadKey();
return;
}
// Get access to source site
using (var ctx = new ClientContext("https://mysite.sharepoint.com/sites/demo3"))
{
//Provide count and pwd for connecting to the source
var passWord = new SecureString();
foreach (char c in pwd.ToCharArray()) passWord.AppendChar(c);
ctx.Credentials = new SharePointOnlineCredentials("me@email.com", passWord);
Web web = ctx.Web;
string docSetLibName = "P1";
string docSetFolderName = "Test1";
string folderName = "Foo1";
try
{
List list = EnsureTargetTestFolder(ctx, docSetLibName);
Folder docSet = EnsureTestDocumentSet(ctx, list, docSetFolderName);
MakeStandardFolder(ctx, docSet, folderName);
}catch(Exception exp)
{
Console.ForegroundColor = ConsoleColor.White;
Console.BackgroundColor = ConsoleColor.Black;
Console.WriteLine("ERROR:" + Environment.NewLine);
Console.WriteLine(exp.Message + Environment.NewLine);
Console.WriteLine(Environment.NewLine);
Console.ResetColor();
}
Console.WriteLine("Done...");
}
Console.ReadKey();
}
private static List EnsureTargetTestFolder(ClientContext ctx, string docSetLibName)
{
if (ctx.Web.ListExists(docSetLibName) == false) {
Console.WriteLine(String.Format("List {0} not found... creating new!", docSetLibName));
// Make the list
List newList = ctx.Web.CreateList(ListTemplateType.DocumentLibrary, docSetLibName, false, true, "", true);
newList.AddContentTypeToListByName("DocSetTest");
newList.RemoveContentTypeByName("Document");
newList.EnableFolderCreation = true;
return newList;
}else
{
Console.WriteLine(String.Format("List {0} exists!", docSetLibName));
return ctx.Web.GetListByTitle(docSetLibName);
}
}
private static Folder EnsureTestDocumentSet(ClientContext ctx, List list, string docSetLibName)
{
if (list.RootFolder.FolderExists(docSetLibName) == false)
{
Console.WriteLine(String.Format("Document Set '{0}'does not exist... creating new!", docSetLibName));
Folder fldr = list.RootFolder.CreateDocumentSet(docSetLibName, ctx.Web.GetContentTypeByName("DocSetTest").Id);
return fldr;
}else
{
Console.WriteLine(String.Format("Document Set '{0}\{1}' exists", list.EntityTypeName, docSetLibName));
return list.RootFolder.ResolveSubFolder(docSetLibName);
}
}
private static void MakeStandardFolder(ClientContext ctx, Folder docSet, string folderName)
{
if (docSet.FolderExists(folderName) == false)
{
Console.WriteLine(String.Format("Folder {0} does not exist ... creating new!", folderName));
docSet.CreateFolder(folderName);
}else
{
Console.WriteLine(String.Format("Folder {0} already exists", folderName));
}
}
我已经测试了你提供的步骤。是的,按照你的步骤出现了错误。
我注意到 "DocSetTest ID" 列可能会导致错误:
1.create "DocumentSetName ID"列并共享,出现错误。
2.create "ID"列并共享,出现错误。
3.create "DocumentSetName_ID" 列并共享,效果很好。
4.create "IDDocumentSetName" 列并共享,效果很好。
因此,在使用 OfficeDevPnP.Core 库时,您的 "ID" 或 "DocumentSetName ID" 列可能会发生冲突(可能存在 "ID" 列)。尝试更改列的名称并检查结果。
完成这项工作的诀窍是首先访问并删除 DocumentSetTemplate 的 SharedFields 集合中的字段,然后创建文件夹,然后恢复 SharedFields。以下是用于执行此操作的方法。
private static void HideSharedFields(ClientContext ctx, ContentType ct, out SharedFieldCollection unsharedFields)
{
DocumentSetTemplate docSetTemplate = DocumentSetTemplate.GetDocumentSetTemplate(ctx, ct);
SharedFieldCollection sharedFields = docSetTemplate.SharedFields;
unsharedFields = sharedFields;
ctx.Load(sharedFields);
ctx.ExecuteQueryRetry();
foreach(var fld in sharedFields)
{
Console.WriteLine(String.Format(" - Removing SharedField '{0}'", fld.Title));
docSetTemplate.SharedFields.Remove(fld);
fld.UpdateAndPushChanges(true);
}
docSetTemplate.Update(true);
ctx.ExecuteQueryRetry();
}
private static void RevealSharedFields(ClientContext ctx, ContentType ct, SharedFieldCollection unsharedFields)
{
DocumentSetTemplate docSetTemplate = DocumentSetTemplate.GetDocumentSetTemplate(ctx, ct);
foreach (var fld in unsharedFields)
{
Console.WriteLine(String.Format(" + Adding SharedField '{0}'", fld.Title));
docSetTemplate.SharedFields.Add(fld);
fld.UpdateAndPushChanges(true);
}
docSetTemplate.Update(true);
ctx.ExecuteQueryRetry();
}
我试图将文件夹添加到文档库中的自定义文档集。但是,一个或多个字段有些不对,并且以下错误消息没有向我提供可以缩小范围的信息。我正在寻找一种方法来识别和修复库中有问题的字段。
Microsoft.SharePoint.Client.ServerException was unhandled
HResult=-2146233088
Message=One or more field types are not installed properly. Go to the list settings page to delete these fields.
ServerErrorCode=-2130575340
ServerErrorTraceCorrelationId=0e7a749d-70a8-2000-36cf-14f8618874a2
ServerErrorTypeName=Microsoft.SharePoint.SPException
ServerStackTrace=""
Source=Microsoft.SharePoint.Client.Runtime
StackTrace:
at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb)
at Microsoft.SharePoint.Client.ClientRequest.ExecuteQuery()
at Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQuery()
at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
at Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryImplementation(ClientRuntimeContext clientContext, Int32 retryCount, Int32 delay)
at Microsoft.SharePoint.Client.FileFolderExtensions.CreateFolderImplementation(FolderCollection folderCollection, String folderName, Folder parentFolder)
at Microsoft.SharePoint.Client.FileFolderExtensions.CreateFolder(Folder parentFolder, String folderName)
at AddFolderToDocSet.Program.Main(String[] args) in C:\Users\user\Documents\Visual Studio 2015\Projects\PnPCoreTest\AddFolderToDocSet\Program.cs:line 51
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
这是我用来添加利用 PNP-Sites-Core library.
的文件夹的代码// Get Root Folders collection for
var projLibRootFldrs = prjLib.RootFolder;
ctx.Load(projLibRootFldrs, pf => pf.Folders);
ctx.ExecuteQueryRetry();
// Get the Document Set
Folder f = projLibRootFldrs.EnsureFolder("Test1");
f.CreateFolder("foo"); // Error here
更新:2016 年 4 月 21 日
经过艰苦的分析(错误...尝试,错误,永远重复)我已经将其缩小到 "Document Set Settings" 的 "Shared Columns" 部分的字段似乎当我检查任何其中发生错误。当我取消选中所有字段以便共享 none 时,我可以添加文件夹。
更新:2016 年 4 月 26 日
以下是重现此错误所需的具体步骤。
这是用于创建文件夹的确切控制台程序:
static void Main(string[] args)
{
string pwd = System.Environment.GetEnvironmentVariable("SOME_PWD", EnvironmentVariableTarget.User);
if (string.IsNullOrEmpty(pwd))
{
System.Console.Write("MSOPWD user environment variable empty, cannot continue. Press any key to end.");
System.Console.ReadKey();
return;
}
// Get access to source site
using (var ctx = new ClientContext("https://mysite.sharepoint.com/sites/demo3"))
{
//Provide count and pwd for connecting to the source
var passWord = new SecureString();
foreach (char c in pwd.ToCharArray()) passWord.AppendChar(c);
ctx.Credentials = new SharePointOnlineCredentials("me@email.com", passWord);
Web web = ctx.Web;
string docSetLibName = "P1";
string docSetFolderName = "Test1";
string folderName = "Foo1";
try
{
List list = EnsureTargetTestFolder(ctx, docSetLibName);
Folder docSet = EnsureTestDocumentSet(ctx, list, docSetFolderName);
MakeStandardFolder(ctx, docSet, folderName);
}catch(Exception exp)
{
Console.ForegroundColor = ConsoleColor.White;
Console.BackgroundColor = ConsoleColor.Black;
Console.WriteLine("ERROR:" + Environment.NewLine);
Console.WriteLine(exp.Message + Environment.NewLine);
Console.WriteLine(Environment.NewLine);
Console.ResetColor();
}
Console.WriteLine("Done...");
}
Console.ReadKey();
}
private static List EnsureTargetTestFolder(ClientContext ctx, string docSetLibName)
{
if (ctx.Web.ListExists(docSetLibName) == false) {
Console.WriteLine(String.Format("List {0} not found... creating new!", docSetLibName));
// Make the list
List newList = ctx.Web.CreateList(ListTemplateType.DocumentLibrary, docSetLibName, false, true, "", true);
newList.AddContentTypeToListByName("DocSetTest");
newList.RemoveContentTypeByName("Document");
newList.EnableFolderCreation = true;
return newList;
}else
{
Console.WriteLine(String.Format("List {0} exists!", docSetLibName));
return ctx.Web.GetListByTitle(docSetLibName);
}
}
private static Folder EnsureTestDocumentSet(ClientContext ctx, List list, string docSetLibName)
{
if (list.RootFolder.FolderExists(docSetLibName) == false)
{
Console.WriteLine(String.Format("Document Set '{0}'does not exist... creating new!", docSetLibName));
Folder fldr = list.RootFolder.CreateDocumentSet(docSetLibName, ctx.Web.GetContentTypeByName("DocSetTest").Id);
return fldr;
}else
{
Console.WriteLine(String.Format("Document Set '{0}\{1}' exists", list.EntityTypeName, docSetLibName));
return list.RootFolder.ResolveSubFolder(docSetLibName);
}
}
private static void MakeStandardFolder(ClientContext ctx, Folder docSet, string folderName)
{
if (docSet.FolderExists(folderName) == false)
{
Console.WriteLine(String.Format("Folder {0} does not exist ... creating new!", folderName));
docSet.CreateFolder(folderName);
}else
{
Console.WriteLine(String.Format("Folder {0} already exists", folderName));
}
}
我已经测试了你提供的步骤。是的,按照你的步骤出现了错误。 我注意到 "DocSetTest ID" 列可能会导致错误:
1.create "DocumentSetName ID"列并共享,出现错误。
2.create "ID"列并共享,出现错误。
3.create "DocumentSetName_ID" 列并共享,效果很好。
4.create "IDDocumentSetName" 列并共享,效果很好。
因此,在使用 OfficeDevPnP.Core 库时,您的 "ID" 或 "DocumentSetName ID" 列可能会发生冲突(可能存在 "ID" 列)。尝试更改列的名称并检查结果。
完成这项工作的诀窍是首先访问并删除 DocumentSetTemplate 的 SharedFields 集合中的字段,然后创建文件夹,然后恢复 SharedFields。以下是用于执行此操作的方法。
private static void HideSharedFields(ClientContext ctx, ContentType ct, out SharedFieldCollection unsharedFields)
{
DocumentSetTemplate docSetTemplate = DocumentSetTemplate.GetDocumentSetTemplate(ctx, ct);
SharedFieldCollection sharedFields = docSetTemplate.SharedFields;
unsharedFields = sharedFields;
ctx.Load(sharedFields);
ctx.ExecuteQueryRetry();
foreach(var fld in sharedFields)
{
Console.WriteLine(String.Format(" - Removing SharedField '{0}'", fld.Title));
docSetTemplate.SharedFields.Remove(fld);
fld.UpdateAndPushChanges(true);
}
docSetTemplate.Update(true);
ctx.ExecuteQueryRetry();
}
private static void RevealSharedFields(ClientContext ctx, ContentType ct, SharedFieldCollection unsharedFields)
{
DocumentSetTemplate docSetTemplate = DocumentSetTemplate.GetDocumentSetTemplate(ctx, ct);
foreach (var fld in unsharedFields)
{
Console.WriteLine(String.Format(" + Adding SharedField '{0}'", fld.Title));
docSetTemplate.SharedFields.Add(fld);
fld.UpdateAndPushChanges(true);
}
docSetTemplate.Update(true);
ctx.ExecuteQueryRetry();
}