Home | About | Sematext search-lucene.com search-hadoop.com
 Search Lucene and all its subprojects:

Switch to Plain View
Lucene.Net, mail # user - Lucene.net in Medium Trust


+
Simone Chiaretta 2010-02-10, 19:46
+
Digy 2010-02-10, 20:12
+
Simone Chiaretta 2010-02-10, 23:57
+
Nicholas Paldino [.NET/C#... 2010-02-13, 06:08
+
Simone Chiaretta 2010-02-13, 11:29
+
Simone Chiaretta 2010-02-16, 16:22
+
digy digy 2010-02-16, 16:39
+
Simone Chiaretta 2010-02-16, 16:59
Copy link to this message
-
Re: Lucene.net in Medium Trust
Simone Chiaretta 2010-05-05, 10:06
Hi All,
sorry for taking so long to work on the issue:
Debugging so far, and found out that the problem was not in the open method,
but in the static constructor itself

1 - FSDirectory static constructor:
public static readonly System.String LOCK_DIR SupportClass.AppSettings.Get("Lucene.Net.lockDir",
System.IO.Path.GetTempPath());
GetTempPath raises a permission exception when running in medium trust...
since this is even an Obsolete method I just removed the line

2 - Utils.Constants static constructor:
System.Environment.GetEnvironmentVariable: raises an exception medium trust
as well:
The lines with problems are:

   - public static readonly System.String OS_NAME    System.Environment.GetEnvironmentVariable("OS") ?? "Linux";
   Just hardcoded "Windows" as I'm not running on other machines... I also
   searched for usages and it's used only in two lines: one in the Directory
   Open method in an if/else statement that does the same things in both trees,
   and the other is in the IndexWriter where the DEFAULT_MAX_SYNC_PAUSE_SECONDS
   is set based on whether it's Windows
   - public static readonly System.String OS_ARCH    System.Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
   Used only as debugging info, so hardcoded it to x86
   - public static readonly System.String OS_VERSION    System.Environment.OSVersion.ToString()
   Used only in debugging, hardcoded to String.Empty
With these changes it works even when setting the trust level to medium:
tested adding
<trust level="Medium" originUrl=".*" />
in the config file of the applications

hope this helps
Simo

PS: I also found this blog post that talks about the same problems:
http://www.klopfenstein.net/lorenz.aspx/lucene.net-on-medium-trust-nhibernate-search-part-2
<http://www.klopfenstein.net/lorenz.aspx/lucene.net-on-medium-trust-nhibernate-search-part-2>Too
bad he didn't publish any code, but only released the compiled build file.

On Tue, Feb 16, 2010 at 6:39 PM, digy digy <[EMAIL PROTECTED]> wrote:

> The reason may be the "FlushFileBuffers" in
> "SupportClass.FileSupport.Sync".
> Can you change the code as below and try again?
>
> public static void Sync(System.IO.FileStream fileStream)
> {
>   if (fileStream == null) throw new ArgumentNullException("fileStream");
>   fileStream.Flush();
> }
>
> DIGY
>
> On Tue, Feb 16, 2010 at 6:22 PM, Simone Chiaretta <
> [EMAIL PROTECTED]> wrote:
>
> > This is the email from the guy that reported the error:
> >
> > It seems like adding the permission to App_Data (where the indexes are
> > located) didn't help.
> >
> > Any ideas?
> > Simone
> >
> > -----------------------------
> >
> > After adding Read/Write/Modify permissions to App_Data for "NETWORK
> > SERVICE" (what the app pool is running under), I got the same
> > permissions issue... but then also got a new one.
> >
> > I added the permissions and did a full IISRESET. I then hit the
> > successfully upgraded site (going to the admin page). The login screen
> > for the admin site came up and I entered my credentials. That's when I
> > got the exception we saw earlier:
> >
> > [SecurityException: Request for the permission of type
> > 'System.Security.Permissions.SecurityPermission, mscorlib,
> > Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
> > failed.]
> >  FileSupport.Sync(FileStream fileStream) +0
> >  Lucene.Net.Store.FSDirectory.Sync(String name) +151
> >  Lucene.Net.Index.SegmentInfos.FinishCommit(Directory dir) +171
> >  Lucene.Net.Index.IndexWriter.Init(Directory d, Analyzer a, Boolean
> > create, Boolean closeDir, IndexDeletionPolicy deletionPolicy, Boolean
> > autoCommit, Int32 maxFieldLength, IndexingChain indexingChain,
> > IndexCommit commit) +257
> >  Lucene.Net.Index.IndexWriter.Init(Directory d, Analyzer a, Boolean
> > closeDir, IndexDeletionPolicy deletionPolicy, Boolean autoCommit,
> > Int32 maxFieldLength, IndexingChain indexingChain, IndexCommit commit)
> > +110
> >  Lucene.Net.Index.IndexWriter..ctor(Directory d, Analyzer a,

Simone Chiaretta
Microsoft MVP ASP.NET - ASPInsider
Blog: http://codeclimber.net.nz
RSS: http://feeds2.feedburner.com/codeclimber
twitter: @simonech

Any sufficiently advanced technology is indistinguishable from magic
"Life is short, play hard"
+
Simone Chiaretta 2010-05-06, 15:53
+
Digy 2010-05-06, 16:09
+
Simone Chiaretta 2010-05-07, 08:08
+
Noel Lysaght 2010-02-16, 16:56
+
Simone Chiaretta 2010-02-16, 16:59