[ 
https://issues.apache.org/jira/browse/LUCENENET-324?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12788244#action_12788244
 ] 

Robert Jordan commented on LUCENENET-324:
-----------------------------------------

Mono does not throw an exception in this case. At least not in an version 
released in the last 2 years.


> System.TypeInitializationException on linux
> -------------------------------------------
>
>                 Key: LUCENENET-324
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-324
>             Project: Lucene.Net
>          Issue Type: Bug
>         Environment: debian, vbnc, Visual Basic
>            Reporter: Johannes von Drachenfels
>            Priority: Minor
>         Attachments: Constants.patch, Constants.patch
>
>
> Problem:
> When the environment variable "OS" is not present a failure occurs when 
> initializing an  Lucene.Net.Store.FSDirectory 
> --------------------------------------------------------------------
> Exception:
> --------------------------------------------------------------------
> > ################################
> >
> > System.TypeInitializationException: An exception was thrown by the 
> > type initializer for Lucene.Net.Store.FSDirectory --->
> > System.TypeInitializationException: An exception was thrown by the 
> > type initializer for Lucene.Net.Util.Constants --->
> > System.NullReferenceException: Object reference not set to an instance 
> > of an object
> >
> >    at Lucene.Net.Util.Constants..cctor () [0x00000]
> >
> >    --- End of inner exception stack trace ---
> >
> >    at Lucene.Net.Store.FSDirectory..cctor () [0x00000]
> >
> >    --- End of inner exception stack trace ---
> >
> >    at ConsoleApplication1.Module1.Main () [0x00000]
> Solution:
> --------------------------------------------------------------------
> This is probably caused by this line in Lucene.Net.Util.Constants.cs:
> public static readonly System.String OS_NAME = 
> System.Environment.GetEnvironmentVariable("OS");
> Try to assign some value to the env var "OS":
>       OS=foo mono yourapp.exe
> Robert
> Workarround:
> --------------------------------------------------------------------
>             'bugfix:
>             Dim OSSTRING As String = ""
>             Try
>                 OSSTRING = System.Environment.GetEnvironmentVariable("OS")
>             Catch ex As Exception
>                 OSSTRING = ""
>             End Try
>             If OSSTRING.Trim.Length = 0 Then
>                 System.Environment.SetEnvironmentVariable("OS", "linux")
>             End If

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to