System.Runtime.Serialization.SerializationException Message: Unable to find assembly 'Lucene.Net

在站点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,程序能运行,但是每过一段时间后会被回收(不是合法的回收,会有错误)。

九州编程
浏览 559回答 2
2回答

繁花如伊

回收是因为你的应用程序池回收了,可以设置IIS 把回收时间加长。序列化问题可能是你的某个文件用了较老版本的 lucene.net 生成,然后反序列化时又用了新版本的 lucene.net ,由于 binary serialize 时会把一些版本和类的信息写到序列化的文件中,如果对不上,就可能失败。
打开App,查看更多内容
随时随地看视频慕课网APP