2012-07-02 7 views
2

MVCSiteMapProvider를 사용하여 응용 프로그램의 현지화 된 메뉴를 생성하고 있습니다. 메뉴에 대한 리소스 파일이 App_GlobalResources 폴더에있는 한 내 프로그램은 잘 작동합니다. 리소스를 다른 폴더로 옮기면 리소스를 찾을 수 없다는 오류가 발생합니다. MVC.sitemap 파일의 리소스에 액세스하는 데 $resources:Resource,menu_Home을 사용하고 있습니다. 리소스 파일을 App_GlobalResources 폴더에 저장하지 않고 사용자 지정 폴더에 보관하려고합니다. 누구든지 도와 줄 수 있습니까?MVCSiteMapProvider 리소스 파일

+0

.NET Framework의 XmlSiteMapProvider에 기본 제공되는 기본 지역화 기능을 사용하여이 작업을 수행 할 수 있다고 생각하지 않습니다. http://msdn.microsoft.com/en-us/library /ms178427(v=vs.100).aspx. 그러나 그것이 바뀔 수 있다면 그것은 효과가있을 것입니다. – Xharze

+0

나는 모든 곳에서 검색했습니다 ... 그런 것 같습니다. : -/ – SDK

+0

나는 동일한 문제가있다. MVC 응용 프로그램의 리소스가 다른 곳으로 배치 되었기 때문에 해결되지 않은 이유를 이해할 수는 없지만 테스트 목적으로 App_GlobalResources에 배치했습니다. – Jaime

답변

0

그 때문에 MvcSiteMapNode.Title 속성에 다음 코드의 발생 :

var implicitResourceString = GetImplicitResourceString("title"); 
if (implicitResourceString != null && implicitResourceString == this["title"]) 
{ 
    return implicitResourceString; 
} 
implicitResourceString = GetExplicitResourceString("title", this["title"], true); 
if (implicitResourceString != null && implicitResourceString == this["title"]) 
{ 
    return implicitResourceString; 
} 

GetExplicitResourceString() 메소드에서 최종 파라미터 throwIfNotFound을 의미하는 사실이다. 그래서 예외가 발생합니다.

if (!string.IsNullOrEmpty(title)) 
{ 
    if (Provider.EnableLocalization) 
    { 
     try 
     { 
      if (!string.IsNullOrEmpty(title) && title.Contains(".")) 
      { 
       int idx = title.LastIndexOf(","); 
       string res = title.Substring(0, idx); 
       string assembly = title.Substring(idx + 1); 

       idx = res.LastIndexOf("."); 
       string type = res.Substring(0, idx); 
       string key = res.Substring(idx + 1); 
       var rm = new ResourceManager(type, Assembly.Load(assembly)); 
       return rm.GetString(key); 
      } 
     } 
     catch 
     { 
     } 
     return title; 
    } 
} 

대신 제목 = "$ 자원 : 자원, 키"의 .sitemap 파일 내부 : 구문을 사용 제목 = "Namespace.Class.Property, 총회"나는 다음 코드를 사용하여 위의 코드를 대체하여 고정 강력한 유형의 생성 클래스를 사용하여 임베디드 리소스를 사용할 때 더욱 적합한 구문입니다.