Github user Metamorphus commented on the issue:
https://github.com/apache/lucenenet/pull/191
@NightOwl888 Thanks for the detailed explanation. I'll get my first touch
to it at weekend, but I anticipate a lot of problems, since I'm only a junior
developer (e.g. I'm not even familiar with NUnit). That's why don't count on me
for now. I'll give the final answer next week.
Right now, however, I'm facing another problem. I use basic Lucene
operations (add document and search by query) in my project and it works well,
when I run the project via `dotnet run`, but when i publish the project and run
its dll, I get this error:
`fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HL0L6Q75SUEF": An unhandled exception was thrown by
the application.
System.TypeInitializationException: The type initializer for
'Lucene.Net.Util.Constants' threw an exception. --->
System.TypeInitializationException: The type initializer for
'Lucene.Net.Support.Configuration.Configuration' threw an exception. --->
System.NullReferenceException: Object reference not set to an instance of an
object.
at
Lucene.Net.Support.Configuration.KeyValueParser.AddToDictionary(XElement
element, Stack`1 context, SortedDictionary`2 results)
at Lucene.Net.Support.Configuration.KeyValueParser.ParseElement(XElement
element, Stack`1 context, SortedDictionary`2 results)
at Lucene.Net.Support.Configuration.KeyValueParser.ParseElement(XElement
element, Stack`1 context, SortedDictionary`2 results)
at Lucene.Net.Support.Configuration.KeyValueParser.ParseElement(XElement
element, Stack`1 context, SortedDictionary`2 results)
at
Lucene.Net.Support.Configuration.ConfigFileConfigurationProvider.ParseElement(XElement
element, Stack`1 context, SortedDictionary`2 results)
at
Lucene.Net.Support.Configuration.ConfigFileConfigurationProvider.Load()
at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1
providers)
at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
at Lucene.Net.Support.Configuration.Configuration..cctor()
--- End of inner exception stack trace ---
at Lucene.Net.Support.Configuration.Configuration.GetAppSetting(String
key)
at Lucene.Net.Support.AppSettings.Get(String key, String defValue)
at Lucene.Net.Util.Constants..cctor()
--- End of inner exception stack trace ---
at Lucene.Net.Index.DocumentsWriterPerThread..ctor(String segmentName,
Directory directory, LiveIndexWriterConfig indexWriterConfig, InfoStream
infoStream, DocumentsWriterDeleteQueue deleteQueue, Builder fieldInfos)
at Lucene.Net.Index.DocumentsWriter.EnsureInitialized(ThreadState state)
at Lucene.Net.Index.DocumentsWriter.UpdateDocument(IEnumerable`1 doc,
Analyzer analyzer, Term delTerm)
at Lucene.Net.Index.IndexWriter.UpdateDocument(Term term, IEnumerable`1
doc, Analyzer analyzer)
at Lucene.Net.Index.IndexWriter.AddDocument(IEnumerable`1 doc, Analyzer
analyzer)
at CCC.Repositories.GenericModelRepository`1.Add(T item, String
username) in C:\Projects\CCC\src\Repositories\GenericModelRepository.cs:line 85
at CCC.Controllers.ApiController`1.Post(T entity) in
C:\Projects\CCC\src\Controllers\ApiController.cs:line 75
at CCC.Controllers.BlogsApiController.Post(Blog item) in
C:\Projects\CCC\src\Controllers\BlogApiController.cs:line 35
at lambda_method(Closure , Object , Object[] )`
Me and my team were struggling with this the whole afternoon, and then we
found this code fragment in
Lucene.Net.Core\Support\Configuration\Configuration.cs file:
`var entryAssembly = Assembly.GetEntryAssembly();
var configurationFiles = new string[0];
if (entryAssembly != null)
{
var directory = Path.GetDirectoryName(entryAssembly.Location);
configurationFiles = Directory.GetFiles(directory, "*.config");
}`
So basically, it looks at the directory, where application assembly is
located, and grabs our web.config file, and treats it as its own configuration
file. Is this correct behavior?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---