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
C# 从SharePoint网站检索托管属性_C#_Sharepoint_Sharepoint 2010 - Fatal编程技术网

C# 从SharePoint网站检索托管属性

C# 从SharePoint网站检索托管属性,c#,sharepoint,sharepoint-2010,C#,Sharepoint,Sharepoint 2010,我试图简单地检查特定属性的托管属性列表。理论上,这并不难。事实证明,这给我带来了麻烦。我发现的第一种方法如下: static void Main(string[] args) { try { string strURL = "http://<SiteName>"; Schema sspSchema = new Schema(SearchContext.GetContext(new SPSite(strURL)));

我试图简单地检查特定属性的托管属性列表。理论上,这并不难。事实证明,这给我带来了麻烦。我发现的第一种方法如下:

static void Main(string[] args)
    {
     try
      {
        string strURL = "http://<SiteName>";
        Schema sspSchema = new Schema(SearchContext.GetContext(new SPSite(strURL)));
        ManagedPropertyCollection properties = sspSchema.AllManagedProperties;
        foreach (ManagedProperty property in properties)
         {
           if (property.Name.Equals("ContentType")
            {
              Console.WriteLine(property.Name);
            }
         }
       }
     catch(Exception ex)
        {
          Console.WriteLine(ex.ToString());
        }
    }
我遇到的问题是
EndpointNotFoundException
。 我猜我只是错误地配置了第二个选项,因为第一个方法可以发现一切都很好。有谁能解释一下我遗漏的明显错误吗?
任何提示/提示将不胜感激

这段代码应该可以满足您的需要

foreach (SPService service in SPFarm.Local.Services)
{
    if (service is SearchService)
    {
        SearchService searchService = (SearchService)service;

        foreach (SearchServiceApplication ssa in searchService.SearchApplications)
        {
            Schema schema = new Schema(ssa);

            foreach (ManagedProperty property in schema.AllManagedProperties)
            {
                if (property.Name == "ContentType")
                {
                    //Handle here
                }
            }
        }
    }
}
foreach (SPService service in SPFarm.Local.Services)
{
    if (service is SearchService)
    {
        SearchService searchService = (SearchService)service;

        foreach (SearchServiceApplication ssa in searchService.SearchApplications)
        {
            Schema schema = new Schema(ssa);

            foreach (ManagedProperty property in schema.AllManagedProperties)
            {
                if (property.Name == "ContentType")
                {
                    //Handle here
                }
            }
        }
    }
}