2008-10-11 4 views
2

공유 호스트의 ASP.NET 응용 프로그램에서 Lucene.Net을 사용하고 있습니다. 아래에 표시된 스택 추적을 얻었습니다. 그 해결 방법은 뭐니?GetTempPath()를 호출하기 때문에 Lucene.Net이 내 호스트에서 실패합니다. 그 해결 방법은 뭐니?

[에, SecurityException가 :. 유형의 허가 요청 'System.Security.Permissions.EnvironmentPermission, mscorlib에, 버전 = 2.0.0.0, 문화 = 중립, PublicKeyToken = b77a5c561934e089은'실패] System.Security.CodeAccessSecurityEngine.Check (개체 요구, StackCrawlMark & stackMark, 부울 isPermSet) +0 System.Security.CodeAccessPermission.Demand() +59 System.IO.Path.GetTempPath() +54 Lucene.Net.Store.FSDirectory..cctor() + 73

답변

2

다음은 내 질문에 대한 답변입니다.

// Comments out by Corey Trager, Oct 2008 to workaround permission restrictions at shared host. This is not used. 
//  public static readonly System.String LOCK_DIR = SupportClass.AppSettings.Get("Lucene.Net.lockDir", System.IO.Path.GetTempPath()); 

하나 개 이상의 보안 권한 장애물 그 후이 있었다, 여기 너무 그 해결 방법입니다 :이 솔루션이 사용되지 않는 라인을 주석에 의해, Lucene.Net.Store.FSDirectory을 수정했다. 디렉터리에있는 파일의 이름을 가져 오는 한 가지 방법이 차단되고 다른 방법으로 차단되지 않는 이유를 이해할 수 없습니다.

public override System.String[] List() 
    { 

/* Changes by Corey Trager, Oct 2008, to workaround permission restrictions at shared host */ 
      System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(directory.FullName); 
      System.IO.FileInfo[] files = dir.GetFiles(); 
      string[] list = new string[files.Length]; 
      for (int i = 0; i < files.Length; i++) 
      { 
       list[i] = files[i].Name; 
      } 
      return list; 
/* end of changes */ 

//   System.String[] files = SupportClass.FileSupport.GetLuceneIndexFiles(directory.FullName, IndexFileNameFilter.GetFilter()); 
//   for (int i = 0; i < files.Length; i++) 
//   { 
//    System.IO.FileInfo fi = new System.IO.FileInfo(files[i]); 
//    files[i] = fi.Name; 
//   } 
//   return files; 
     }