【问题标题】:Problems with localized data annotations in an Azure/RIA/Silverlight applicationAzure/RIA/Silverlight 应用程序中的本地化数据注释问题
【发布时间】:2011-08-04 09:31:44
【问题描述】:

我很难在 Azure / RIA / Silverlight 应用程序中创建本地化数据注释。

这是我所拥有的以及到目前为止我所做的:

  • 我有一个 Base 项目,其中包含数据模型以及我们在整个解决方案中使用的一些全局常量。命名空间是GOLTracker.Base
  • 在这里,我放置了我的.resx 并为其中一个类定义了一些基本的显示信息。

这是一段代码,它定义了其中一个类并使用了资源文件:

 public partial class Vehicle : TableEntity
 {
    [Required]
    [Bindable(true, BindingDirection.TwoWay)]
    [Display(Name = "VehicleNameLabel", Description = "VehicleNameDescription", ResourceType = typeof(DisplayResources))]
    public string Name { get; set; }
    (...)
 }
  • 其次是我的GOLTracker.Role项目,是Azure中的主要角色。它包含承载 Silverlight 应用程序的网页。这里没有资源。它还包含 BoardDomainService 类,其中包含用于获取数据的查询。
  • 最后,GOLTracker.Board. 中有两个 Silverlight 应用程序:GuiMapControlGui。两者都使用数据模型。在这两个应用程序中,我都添加了指向资源文件的链接(.resx.cs)。

另外,我编辑了 Silverlight 项目文件以包含本地化信息:

<SupportedCultures>
  en-US;pl-PL
</SupportedCultures>

一切都正确编译。但是,当我尝试在任何使用 Vehicle 类的 Silverlight 应用程序上打开页面时,我得到以下异常:

Message: System.ServiceModel.DomainServices.Client.DomainException: An error occurred
while loading data through the 'GetVehicles' query on DomainContext of type
'BoardDomainContext' and the error was not handled.  If this error is expected, then
you must handle the LoadedData event on the DomainDataSource and call
LoadedDataEventArgs.MarkErrorAsHandled() to avoid this exception.

Exception has been thrown by the target of an invocation. --->
System.Reflection.TargetInvocationException: Exception has been thrown by the target
of an invocation. ---> System.Resources.MissingManifestResourceException: Could not
find any resources appropriate for the specified culture or the neutral culture.  Make
sure "ARP.GOLTracker.Base.Resources.DisplayResources.resources" was correctly embedded
or linked into assembly "ARP.GOLTracker.Board.MapControlGui" at compile time, or that
all the satellite assemblies required are loadable and fully signed.

说实话,我不知道是什么原因;链接的.resx 文件应该是嵌入式资源。我不知道还缺少什么。

请帮忙。

【问题讨论】:

  • 好像无法从 ARP.GOLTracker.Base.Resources.DisplayResources.resources 加载资源,你这里有什么资源?
  • 只是在Vehicle 类中定义的两个用于测试目的。所以VehicleNameLabelVehicleNameDescription

标签: c# silverlight localization azure wcf-ria-services


【解决方案1】:

我找到了解决问题的方法。我不能说我喜欢它,因为它表明在生成代码时发生了一些丑陋的事情。

找到here 的解决方案围绕着将&lt;LogicalName&gt; 添加到SL 项目文件中链接.resx. 的定义中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多