0

如何让Lucene.NET 2.3.2 在中等信任环境中运行?GoDaddy不喜欢它现在的样子。

4

3 回答 3

1

我最近刚刚为此苦苦挣扎,并想用我必须工作的解决方案来更新它。我下载了最新的代码并自己构建了它,以便在需要时进行更改。在 SupportClass.cs 文件中,从第 481 行开始,有一些代码可以验证文件缓冲区是否已使用非托管代码刷新。

        if (OS.IsWindows)
        {
            if (!FlushFileBuffers(fileStream.Handle))
                throw new System.IO.IOException();
        }
        else if (OS.IsUnix)
        {
            if (fsync(fileStream.Handle) != IntPtr.Zero)
            throw new System.IO.IOException();
        }
        else
        {
            throw new NotImplementedException();
        }

我注释掉了这些行并重建了库,并且能够以中等信任度运行。我以中等信任度在本地运行,并将部署到 GoDaddy 的简单测试应用程序放在一起。我不确定删除这些行会有什么影响。他们似乎在复制fileStream.Flush()此块之前的调用行为,但我不确定。

于 2011-04-28T20:21:06.943 回答
1

它应该工作。Lucene.NET在提交788091788092中与中等信任环境兼容,这两个版本已进入 2.3.2 版本。您可以通过使用您最喜欢的Subversion客户端查看2.3.2 标记的历史来验证这一点。

于 2009-12-03T02:15:08.407 回答
0

我刚刚在 lucene 用户组中发布了这个问题,建议您使用以下内容:-

public static void Sync(System.IO.FileStream fileStream)
{
  if (fileStream == null)
    throw new ArgumentNullException("fileStream");

  //Will only compile with .net 4.0
  fileStream.Flush(true);
}

来自用户组电子邮件的报价:-

However, at the time, Lucene.NET was built on .NET 2.0 (IIRC) and didn't have access to the overload of the Flush method which was used to guarantee everything was flushed to disk:

http://web.archiveorange.com/archive/v/3k9XU33O4yJyW15fWfMd#MhNDlmKgnUj5fOj

Since you are now working in .NET 4.0, you should be able to replace the above code in SupportClass.cs

于 2011-05-01T15:54:46.193 回答