首页 新闻 赞助 找找看

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

-1
悬赏园豆:80 [已解决问题] 解决于 2012-04-19 13:14

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

today4king的主页 today4king | 老鸟四级 | 园豆:3499
提问于:2012-04-17 15:15
< >
分享
最佳答案
0

已经解决了,原因如下:

出现这个问题的原因在于未处理异常的默认策略在 .NET Framework 2.0 中已发生更改。默认情况下,未处理异常的策略是结束工作进程。

在 Microsoft .NET Framework 1.1 和 Microsoft .NET Framework 1.0 中,会忽略托管线程上的未处理异常。除非附加调试程序以捕获异常,否则您可能意识不到出错。

ASP.NET 在 .NET Framework 2.0 中使用未处理异常的默认策略。引发未处理的异常时,基于 ASP.NET 的应用程序将会意外退出。

如果在请求上下文中出现异常,则不会发生上述行为。这类异常仍由 HttpException 对象进行处理和包装。在请求上下文中出现的异常不会导致工作进程结束。但是,请求上下文之外的未处理异常(如计时器线程上或回调函数中的异常)会导致工作进程结束。

http://www.cnblogs.com/jinzhao/archive/2012/04/19/2456930.html

today4king | 老鸟四级 |园豆:3499 | 2012-04-19 13:14
其他回答(1)
0

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

收获园豆:80
eaglet | 园豆:17139 (专家六级) | 2012-04-19 08:57
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册