CSLA Silverlight Resource dll

CSLA Silverlight Resource dll

Old forum URL: forums.lhotka.net/forums/t/10168.aspx


richardp posted on Monday, March 14, 2011

Hi, we are developing a 3 tier CSLA Silverlight app.

The ability to translate to different languages is a key requirement.

I have tried storing the localizable strings in a dedicated resource dll, which is referenced by both Library.Server.dll and Library.Client.dll. So I have Library.Resource.Server.dll and Library.Resource.Client.dll. I used the trick of adding a file as a link to share the same resource class file between the client and server. The class that is shared is the one that the resource compiler tool produces i.e. Library.Resource.Server.Designer.cs.

This all seems to compile and works on the server side,  however it throws an exception when the client code tries to access a resource string. The exception is something about "missing manifest - missing resource culture".

I read that Silverlight is not able to use resource files compiled as "Embedded Resource", only files compiled as "Resource".

I am a bit stuck now and would welcome any suggestions.

richardp replied on Tuesday, March 15, 2011

OK I figured it out.

It was no use adding the generated resource class file as a link, this class is simply a wrapper around a ResourceManger which retrieves resources that were previously embedded in the assembly.

The resources get embedded in the assembly by the PublicResXFileCodeGenerator tool.

You can't run this tool against a linked .resx file.

The best solution I found was to have identical, duplicate resource dlls, one for the server and one for the Silverlight client. I set a post-build step on the server resource dll to copy the server resx file to the client resource dll project. This keeps the 2 files in sync. I have to remember to only edit the server resource dll, as the client resource dll will get over-written on each build.

RockfordLhotka replied on Tuesday, March 15, 2011

I don't know exactly how your solution/project is configured. But the Csla.Silverlight project uses linked resource files from the Csla main project.

Jonny did this, and it might be that he had to manually edit the csproj file to make it work - I'm not sure. I do believe we had to do some manual csproj editing for either SL or WP7, and I don't remember the exact circumstances.

richardp replied on Tuesday, March 15, 2011

Aha! I found the linked resource files in the Csla.Silverlight project and replicated what you did there and it is all working now.

Thanks heaps Rocky!

Richard.

Copyright (c) Marimer LLC