SharePoint功能收缩会杀死应用程序池
本文关键字:应用 应用程序 程序池 功能 SharePoint | 更新日期: 2023-09-27 18:11:30
本周早些时候,我公司的解决方案设计师最近向所有开发人员发出了一个挑战,要求他们找到他编写的一些代码中的错误。发生的事情是,当一些问题出现时,构建管理员从SharePoint撤回了他的解决方案包,整个应用程序池都死了。
据推测,原因是以下之一:
- 代码中的内容
- 是否与从中央管理部门撤回解决方案有关?
- C -以上都不是
- D -以上所有
我今天一直在看代码,但没有发现任何问题。我想我应该把他的代码放在这里,并从任何有兴趣给出一个的人那里得到一个意见。这不是一个严肃的问题,这个挑战是出于善意,所以如果你愿意的话,请给予它任何关注。
来自SD的消息:
正如我昨天在DevDays中提到的,当SharePoint管理员从SharePoint中收回CityDepartments解决方案包时,整个IIS应用程序池就死了。这是在owtimer . exe计时器作业可以解锁所有它锁定的Web应用程序和网站之前,在实际功能被停用之前。
所以,既然没有人知道哪里出了问题,我将奖励第一个找出问题的人(包括我自己)。
正如我所承诺的,如果你能在一个功能失效事件中发现问题,导致SharePoint崩溃,就像上周发生的那样,那么我将给你买两张电影票,看目前正在放映的任何一部NuMetro或SterKinekor电影。证据将是在DEV和QA环境中成功部署和收回固定的解决方案包(3次只是为了确保)。
List Feature Event Receiver:
using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.Taxonomy;
using Microsoft.Office.DocumentManagement.MetadataNavigation;
using Microsoft.Office.Server.SocialData;
namespace CityDepartmentStructure.SharepointExtractTimerJob.Features.CityDepartmentsListFeature
{
/// <summary>
/// This class handles events raised during feature activation, deactivation, installation, uninstallation, and upgrade.
/// </summary>
/// <remarks>
/// The GUID attached to this class may be used during packaging and should not be modified.
/// </remarks>
[Guid("ce0a04a0-b20b-4587-998a-6817dce2d4d8")]
public class CityDepartmentsListFeatureEventReceiver : SPFeatureReceiver
{
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
try
{
SPServiceContext context = SPServiceContext.GetContext(SPServiceApplicationProxyGroup.Default, SPSiteSubscriptionIdentifier.Default);
SocialTagManager stm = new SocialTagManager(context);
TaxonomySession taxonomySession = stm.TaxonomySession;
TermStore termStore = taxonomySession.DefaultSiteCollectionTermStore;
Group termGroup = termStore.Groups["CityDepartments"];
TermSet termSet = termGroup.TermSets["Directorates"];
using (SPWeb web = properties.Feature.Parent as SPWeb)
{
web.Lists.Add("DepartmentSites", "This list maintains a list of web sites for all Org Units in CCT", SPListTemplateType.Links);
web.Update();
SPList departmentsList = web.Lists["DepartmentSites"];
TaxonomyField taxonomyField = departmentsList.Fields.CreateNewField("TaxonomyFieldType", "OrgLevel") as TaxonomyField;
taxonomyField.Description = "Org Unit in the Org Structure. Can be a Directorate, Department, Branch or Section.";
taxonomyField.SspId = termStore.Id;
taxonomyField.TermSetId = termSet.Id;
taxonomyField.AllowMultipleValues = false;
taxonomyField.CreateValuesInEditForm = false;
taxonomyField.Open = false;
taxonomyField.Group = "CCT Metadata Field Content Type";
taxonomyField.Required = true;
departmentsList.Fields.Add(taxonomyField);
TaxonomyField field = departmentsList.Fields["OrgLevel"] as TaxonomyField;
field.Title = "OrgLevel";
field.Update(true);
departmentsList.Update();
SPView view = departmentsList.DefaultView;
view.ViewFields.Add("OrgLevel");
view.Update();
var navigationField = departmentsList.Fields["OrgLevel"] as SPField;
MetadataNavigationSettings navigationSettings = MetadataNavigationSettings.GetMetadataNavigationSettings(departmentsList);
MetadataNavigationHierarchy navigationHierarchy = new MetadataNavigationHierarchy(navigationField);
navigationSettings.AddConfiguredHierarchy(navigationHierarchy);
MetadataNavigationSettings.SetMetadataNavigationSettings(departmentsList, navigationSettings, true);
departmentsList.Update();
MetadataNavigationKeyFilter navigationKeyFilter = new MetadataNavigationKeyFilter(navigationField);
navigationSettings.AddConfiguredKeyFilter(navigationKeyFilter);
MetadataNavigationSettings.SetMetadataNavigationSettings(departmentsList, navigationSettings, true);
departmentsList.Update();
}
}
catch (Exception ex)
{
throw ex;
}
}
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
try
{
using (SPWeb web = properties.Feature.Parent as SPWeb)
{
SPList departmentsList = web.Lists["DepartmentSites"];
departmentsList.Delete();
}
}
catch (Exception ex)
{
throw ex;
}
}
}
}
Timer Job Feature Event Receiver:
using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using System.Linq;
namespace CityDepartmentStructure.SharepointExtractTimerJob.Features.Feature1
{
/// <summary>
/// This class handles events raised during feature activation, deactivation, installation, uninstallation, and upgrade.
/// </summary>
/// <remarks>
/// The GUID attached to this class may be used during packaging and should not be modified.
/// </remarks>
[Guid("10e80e0f-7be3-46f0-8a7f-fcf806ddf762")]
public class Feature1EventReceiver : SPFeatureReceiver
{
private const string JobName = "ExtractTimerJob";
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPService service = GetService();
// Remove job if it exists.
DeleteJobAndSettings(service);
// Create the job.
ExtractTimerJob job = new ExtractTimerJob(JobName, service);
// Create the schedule so that the job runs hourly, sometime
// during the first quarter of the hour.
SPHourlySchedule schedule = new SPHourlySchedule();
schedule.BeginMinute = 0;
schedule.EndMinute = 15;
job.Schedule = schedule;
job.Update();
// Configure the job.
ExtractTimerJobSettings jobSettings = new ExtractTimerJobSettings(service, Guid.NewGuid());
jobSettings.Name = "ExtractTimerJobSettings";
jobSettings.WebServiceLocation = "http://r3pci01.capetown.gov.za:8150/sap/zget_orgstruct";
jobSettings.Update(true);
}
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
DeleteJobAndSettings(GetService());
}
private void DeleteJobAndSettings(SPService service)
{
// Find the job and delete it.
foreach (SPJobDefinition job in service.JobDefinitions)
{
if (job.Name == JobName)
{
job.Delete();
break;
}
}
// Delete the job's settings.
ExtractTimerJobSettings jobSettings = service.GetChild<ExtractTimerJobSettings>("ExtractTimerJobSettings");
if (jobSettings != null)
{
jobSettings.Delete();
}
}
private static SPService GetService()
{
// Get an instance of the SharePoint farm.
SPFarm farm = SPFarm.Local;
// Get an instance of the service.
var results = from s in farm.Services
where s.Name == "SPSearch4"
select s;
SPService service = results.First();
return service;
}
}
}
如果没有日志,可能很难弄清楚到底发生了什么,但我猜处置Properties.Feature.Parent不是一个好主意。
如果你在powershell中这样做,可能会导致一些问题,因为它很可能总是尝试使用相同的对象。
下一件事是,使用你正在部署/撤回解决方案的脚本。你是否每次都明确地激活/停用功能?
对于部署和撤回来说,更多的应用程序池被杀死是正常的行为,但是再次启动它们的问题可能与某种超时有关——例如,应用程序池启动试图在它真正关闭之前发生。