在asp.net网站的Application_Start事件上运行以下代码:</p>
public void CheckRebuildTasks()
{
try
{
var ts = _rebuildRepository.Source.unCompleteRoots();
if (ts.Any())
{
var task = new Task(() =>
{
int s = 30;
string nameList = string.Empty;
try
{
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);
});
}
catch (Exception exc)
{
_log.Error(exc);
}
});
task.LogExceptions("CheckRebuildTasks");
task.Start();
}
}
catch (Exception exc)
{
_log.Error("CheckRebuildTasks", exc);
}
}
windows EventLog消息:</p>
发生未处理的异常,进程终止。应用程序 ID:默认域
进程 ID:19232
异常:System.Runtime.Serialization.SerializationException
消息:找不到程序集“Lucene.Net,版本=2.9.4.1,文化=中性,PublicKeyToken=85089178b9ac3181”。
StackTrace:在 System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly() 在 System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name) 在 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) 在 System.Runtime.Serialization.Formatters.Binary ._ BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped 记录) 在 System.Runtime.Serialization.Formatters.Binary。_BinaryParser.Run()
在 System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) 在 System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler , Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) 在 System.AppDomain.Deserialize(Byte[] blob) 在 System.AppDomain.UnmarshalObject(Byte[] blob)
PS:已经参考了Lucene.Net,程序在本地运行良好