在站点Application_Start中执行如下代码:
public void CheckRebuildTasks() { try { var ts = _rebuildRepository.Source.unCompleteRoots(); if (ts.Any()) { Task.Factory.StartNew(() => { int s = 30; string nameList = string.Empty; ts.ToList().ForEach( t => nameList += string.Format("{0}[{1}]", t.AppName, t.AppContentName)); _log.Info(string.Format("Sleep {0}s to continue {1}", s, nameList)); System.Threading.Thread.Sleep(30*1000); ts.ToList().ForEach(t => { var appContent = _appContentRepository.GetBy(t.AppName, t. AppContentName); this.ClearRebuild(appContent.Name, appContent.ContentType); var si = new SmartIndexer(appContent, _zzkDocumentRepository, _rebuildRepository); si.Rebuild(t); }); }).LogExceptions("CheckRebuildTasks"); } } catch(Exception exc) { _log.Error("CheckRebuildTasks", exc); } }
EventLog中的信息:
An unhandled exception occurred and the process was terminated. Application ID: DefaultDomain Process ID: 43644 Exception: System.Runtime.Serialization.SerializationException Message: Unable to find assembly 'Lucene.Net, Version=2.9.4.1, Culture=neutral, PublicKeyToken=85089178b9ac3181'. StackTrace: at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly() at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name) at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable) at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record) at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run() at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) at System.AppDomain.Deserialize(Byte[] blob) at System.AppDomain.UnmarshalObject(Byte[] blob)
注:已经引用Lucene.Net,程序能运行,但是每过一段时间后会被回收(不是合法的回收,会有错误)。
繁花如伊