c# - 在 Azure 辅助角色中使用 Lucene.NET 引发未处理的异常

标签 c# asp.net azure lucene.net azure-worker-roles

我正在尝试创建一个 Azure 辅助角色,为 Lucene.NET 中的文档编制索引。

但是,当我创建 IndexWriter 时,它失败并出现以下异常:

System.ExecutionEngineException was unhandled
Message: An unhandled exception of type 'System.ExecutionEngineException'
         occurred in mscorlib.dll

如果我将项目构建为 .exe,则一切正常 - 不会引发异常。我正在使用 .NET Framework 4.0。

我的代码:

var cloudAccount = CloudStorageAccount.FromConfigurationSetting("LuceneBlobStorage");
var cacheDirectory = new RAMDirectory();
var azureDirectory = new AzureDirectory(
                                cloudAccount,"SnowballIndex", cacheDirectory);
var analyzer = new SnowballAnalyzer("English");

// !-- Exception thrown after this call
this.indexWriter = new IndexWriter(
             azureDirectory, analyzer, IndexWriter.MaxFieldLength.UNLIMITED);

任何想法将不胜感激。我上网查了一下,没有找到。

谢谢。

最佳答案

我刚刚使用确切的代码测试了我的辅助角色(仅使用标准分析器,并且辅助角色 DLL 的创建没有任何问题。请您尝试隔离这是否可能是使用自定义分析器的问题?也有机会,您是否在同一台计算机上安装了.net 4.5?

如果您可以提供您的 worker 角色项目,我很乐意看一下,看看可能存在什么问题。

编辑于 2012 年 6 月 28 日

在基于 SDK 1.6 的辅助角色中,我只需安装 Lucene.Net.Store.Azure 包,然后在 OnStart() 函数中添加以下代码,并且没有错误:

StorageCredentialsAccountAndKey creds = new StorageCredentialsAccountAndKey(_azure_storage_name_, _azure_storage_key);
CloudStorageAccount cloudAccount = new CloudStorageAccount(creds, true);
Lucene.Net.Util.Version version = Lucene.Net.Util.Version.LUCENE_29;
var cacheDirectory = new RAMDirectory();
IndexWriter indexWriter = null;
AzureDirectory azureDirectory = new AzureDirectory(cloudAccount, "SnowballIndex", cacheDirectory);
Analyzer analyzer = new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29);
indexWriter = new IndexWriter(azureDirectory, analyzer, IndexWriter.MaxFieldLength.UNLIMITED); 

我认为您的问题可能是特定于机器的,因为没有错误并且辅助角色运行良好。

关于c# - 在 Azure 辅助角色中使用 Lucene.NET 引发未处理的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11221235/

相关文章:

c# - <??> 符号在 C#.NET 中意味着什么?

c# - 在html中创建树状结构的简单解决方案

c# - Scala,C# 等效于 F# 事件模式

asp.net - 持续集成基础设施的部署

c# - 在强类型容器模型的情况下,模型参数意味着什么

sql-server - 微软 azure : Could not submit the request to create database 'Name'

azure - Azure 服务总线通知中心是否可以与 websockets 和 javascript 配合使用?

c# - ListView 中的图像与 BackColor 属性不匹配

javascript - ASP.NET 查询字符串第二个值

java - 在 Azure 应用服务中运行 Wildfly,如何配置 JGroups 进行 session 复制