开发者

Problems with localized data annotations in an Azure/RIA/Silverlight application

I'm having a hard time creating localized data annotations in an Azure / RIA / Silverlight application.

Here is what I have and what I've done so far:

  • I have a Base project which contains the data model as well as some global constants we use in the entire solution. The namespace is GOLTracker.Base.
  • Here, I've placed my .resx and defined some basic display info for one of the classes.

Here is a fragment of code which defines one of the classes and makes use of the resource file:

 public partial class Vehicle : TableEntity
 {
    [Required]
    [Bindable(true, BindingDirection.TwoWay)]
    [Display(Name = "VehicleNameLabel", Description = "VehicleNameDescription", ResourceType = typeof(DisplayResources))]
    public string Name { get; set; }
    (...)
 }
  • Second is my GOLTracker.Role project, which is the main role in Azure. It contains the web page which hosts the Silverlight application. There are no resources here. It also contains the BoardDomainService class with queries used to get data.
  • Finally, there are two Silverlight applications in GOLTracker.Board.: Gui and MapControlGui. Both make use of the data model. In both applications I've added links to the resource files (both the .resx and the .cs).

Also, I've edited the Silverlight project files to include localization information:

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

Everything compiles correctly. However, when I try to open a page on any of the Silverlight applications which makes use of the Vehicle class, I get the following exception:

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.MapControlGu开发者_C百科i" at compile time, or that
all the satellite assemblies required are loadable and fully signed.

To be honest, I don't know what is the cause; the linked .resx files are embedded resources as they should be. I don't know what else is missing.

Please help.


I've found a solution to my problem. I can't say I like it, as it suggests there's something ugly going on when code is being generated.

The solution, found here, revolves around adding <LogicalName> to the definitions of linked .resx. in the SL project files.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜