2012-10-04 2 views
1

리소스를 사용하여 MVC 응용 프로그램에서 지역화를 위해 다른 문자열을 저장합니다. JavaScript를 처리하고 리소스의 실제 지역화 된 문자열 값으로 Translate(KEY) 호출을 변경하기 위해 HttpHandler를 사용하고 있습니다. 이 여기에 대한 제공 : Localize text in JavaScript files in ASP.NETgetobject()를 사용하여 MissingManifestResourceException을 던졌습니다.

문제는 내가 내 자원 관리자로부터으로 getObject 메소드를 호출 할 때 내가 여기

MissingManifestResourceException Could not find any resources appropriate for the specified culture or the neutral culture.는 관련 코드 부분 (오류가 아래의 코드에서 6 호선에서 유래)가 얻을 수 있습니다 :

private string TranslateScript(string text) 
{ 
    MatchCollection matches = REGEX.Matches(text); 
    ResourceManager manager = new ResourceManager(typeof(CamelotShiftManagement.Strings.SharedStrings)); 

    foreach (Match match in matches) 
    { 
     object obj = manager.GetObject(match.Groups[1].Value, CultureInfo.CurrentCulture); //This throws the MissingManifestResourceException for some reson!!!! 
     if (obj != null) 
     { 
      text = text.Replace(match.Value, CleanText(obj.ToString())); 
     } 
    } 

    return text; 
} 

내가 뭘 잘못하고 있니?

답변

1

그래, 문제가 발견되었지만 그 이유는 설명 할 수 없습니다. (아직)

이 게시물을 찾았습니다 Problems with ResourceManager and neutral culture in Asp.Net MVC 그리고 그가 한 단계를 따르십시오.

ResourceManager manager = new ResourceManager(typeof(CamelotShiftManagement.Strings.SharedStrings)); 

하려면 :

ResourceManager manager = CamelotShiftManagement.Strings.SharedStrings.ResourceManager; 

는 기본적으로 각각의 리소스 파일이 리소스 파일을 처리하는 ResourceManager에에 정적 referance에있다 그대로 보인다 나는 선을 CHAGE 있습니다.

그게 내 문제를 해결했습니다. 그런데, 내가 전에 사용했던 방법이 효과가 없었던 이유에 대해서는 여전히 확신 할 수 없다 ...