Если вы создали свой собственный тип контента, и он опубликован / активирован в SharePoint, он должен быть доступен для добавления в библиотеку документов.Просто убедитесь, что ваша библиотека документов настроена на поддержку типов содержимого.
В разделе «Дополнительные настройки» в разделе «Настройки библиотеки документов» выберите Yes
в поле «* 1004». Затем продолжите, как и прежде. Настройки -> Добавить из существующих типов контента сайта ..
Вы можете использовать консольное приложение (ref MSDN ) для добавления типа контента в список на вашем сайте.Это также дает вам полезные сообщения о текущем состоянии вещей.
class Program {
static void Main(string[] args) {
using (SPSite siteCollection = new SPSite("http://YOUR_SPSITE")) {
using (SPWeb site = siteCollection.OpenWeb() {
// Get a content type.
SPContentType ct = site.AvailableContentTypes["YOUR_CONTENT_NAME"];
// The content type was found.
if (ct != null)
// Get a list.
try {
SPList list = site.Lists["YOUR_DOCUMENT_LIBRARY_NAME"]; // Throws exception if does not exist.
// Make sure the list accepts content types.
list.ContentTypesEnabled = true;
// Add the content type to the list.
if (!list.IsContentTypeAllowed(ct))
Console.WriteLine("The {0} content type is not allowed on the {1} list",
ct.Name, list.Title);
else if (list.ContentTypes[ct.Name] != null)
Console.WriteLine("The content type name {0} is already in use on the {1} list",
ct.Name, list.Title);
else
list.ContentTypes.Add(ct);
}
catch (ArgumentException ex) // No list is found.
{
Console.WriteLine("The list does not exist.");
}
else // No content type is found.
Console.WriteLine("The content type is not available in this site.");
}
}
Console.Write("\nPress ENTER to continue...");
Console.ReadLine();
}
}