Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is it so hard to share resource files (resx) with my Silverlight client?

I'm trying to share a resource file (.resx file) from my web (RIA Service?Silverlight Host) to client (Silverlight) by linking the resource file into my client. When I try to access resources using the ResourceManager object I get the following error:

System.Resources.MissingManifestResourceException was caught
  Message=Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure "PPCa.Modules.ProjectManager.Client.ViewModels.ResourceStrings.resources" was correctly embedded or linked into assembly "PPCa.Modules.ProjectManager.Client" at compile time, or that all the satellite assemblies required are loadable and fully signed.
  StackTrace:
       at System.Resources.ManifestBasedResourceGroveler.HandleResourceStreamMissing(String fileName)
       at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark)
       at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)
       at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
       at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
       at System.Resources.ResourceManager.GetString(String name)
       at PPCa.Modules.ProjectManager.Web.Helpers.ResourceHelper.GetEnumText[TResource](ProjectStatus a_projectStatus)
  InnerException: 

Edit:

When I say I was linking the resource file, I mean I am using the 'Add as Link' option when adding the existing resx file to my project.

like image 814
Jordan Avatar asked Mar 15 '11 17:03

Jordan


People also ask

What is resources Resx?

The . resx resource file format consists of XML entries that specify objects and strings inside XML tags. One advantage of a . resx file is that when opened with a text editor (such as Notepad) it can be written to, parsed, and manipulated.

How do I open a RESX file?

Navigate to resources from File Structure Open a . resx file in the XML (Text) editor. Press Ctrl+Alt+F or choose ReSharper | Windows | File Structure from the main menu . Alternatively, you can press Ctrl+Shift+A , start typing the command name in the popup, and then choose it there.

What is RESX file in VB NET?

Net Resource (. resx) files are a monolingual file format used in Microsoft . Net Applications. The . resx resource file format consists of XML entries, which specify objects and strings inside XML tags.


2 Answers

I'm currently working through this issue at the moment too. I have narrowed down the issue to namespaces. For me, I created a Silverlight Business Application and I wanted to rename the web project and change its namespace. As soon as I did this, the SL project became broken.

Check this out. The notes on step 5 sort of explain the situation, but I'm currently trying to figure out a decent way around this.

EDIT: This worked for me: http://forums.silverlight.net/forums/p/184013/420509.aspx

like image 96
A.G. Avatar answered Sep 21 '22 20:09

A.G.


A (questionable) solution was to:

  1. copy (vice link) the resx files to the silverlight client.
  2. add "PublicResXFileCodeGenerator" to the Custom Tool property to gen designer.cs file.
  3. Opened designer.cs and changed the namespace back to that of the web designer.cs file.
  4. Build solution to find/adjust related resx namespace issues.

It worked but I question the feasibility of having separate copies of resx files. Other than having to ensure changes to the web resx files are manually duplicated to the silverlight client resx copies, are there any other potential pitfalls ... or is there an alternative solution.

like image 41
Geary M. McIver Avatar answered Sep 24 '22 20:09

Geary M. McIver