2014-04-20 21 views
0

我正在使用mvc4創建應用程序。在我的應用程序中,我在類庫中創建了項目外的resource.resx文件(但是在我的mvc應用程序也位於其中的一個解決方案中)。我想使用resource.resx文件中的標籤名稱或驗證消息。 ,如: -在asp.net mvc4中使用resource.resx文件(在項目中使用類庫之外創建)的分步過程mvc4

public class xyz 
{ 
    [Display(Name = "LBL_name", ResourceType = typeof(Resource.abcd.Resource1))] 
    public string Name1 { get; set; } 

} 

「LBL_name」 在Resource1.resx文件中指定。 「Resource.abcd」是它的自定義工具名稱空間。

我將類庫的引用添加到我的mvc應用程序,並按照this link中的建議設置resource.resx的屬性。

但它提供了以下錯誤

Cannot retrieve property 'Name' because localization failed. 
Type 'Resource.abcd.Resource1' is not public or does not contain a 
public static string property with the name 'LBL_name'. 

我不知道正確使用resource.resx文件。有人可以指導我這一點。

回答

0

在VS的資源編輯器中打開該文件,並確保訪問修飾符參數設置爲Public。

相關問題