Last post Jan 27, 2006 11:56 PM by e2canoe
Jan 27, 2006 02:54 PM|e2canoe|LINK
I am new to .NET.
I am developing a web app which I have architecture to include several class libaries (a BLL, a DAL and a few separate DLLs (assemblies) that provide various classes specific to my app). I think I understand how to localize aspx pages with resx files but
am not sure how to attach resources to my class libary DLLs (I have several class libaries that need to retrieve resources based on the culture of the thread that instantiates a class).
Everything I find on the web on this subject seems to say to create .resource files in the main web app. However, I want my resources to be associated with the class library assembly.
How do I do this?
Also, I read something about making sure the calling app has a SatelliteContractVersion attribute set up correctly so that it is 'allowed' to load resources from a satellite of a different assembly version # that it. Does this apply to class library assemblies
loading resources from satellites as well?
Jan 27, 2006 05:28 PM|e2canoe|LINK
Jan 27, 2006 05:33 PM|StrongTypes|LINK
Jan 27, 2006 07:56 PM|e2canoe|LINK
Error 2 The name 'Resources' does not exist in the current context C:\Documents and Settings\Emmanuel\My Documents\Stratelogics\R and D\Projects\Kingsmere\Development\KingsmereBLL\AccountManagement.cs 115 31 KingsmereBLL
This is the offending line of source in AccountManagement.cs:
msg.FromAddress = Resources.MAIL.en.ActivationEmailFrom;
The resource file is named MAIL.en.resx and is placed in the project's root.
I have also tried "Resources.MAIL.ActivationEmailFrom;" and renaming the resource file to "MAIL.resx".
I have "using Sytem.Resources" at top of file (not sure what you call that).
Could it be that VS.2005 must know to compile .resx files found in the App_GlobalResources directory into class DLLs (so that Resources.<resource filename base>.<resource name> form can be used) but that when resx are included in a class library which doesn't
have an App_GlobalResource dir, it doesn't do anything special with them. But then I've only been using .NET and VS for a couple of months now.
Jan 27, 2006 09:17 PM|StrongTypes|LINK
Jan 27, 2006 09:45 PM|e2canoe|LINK
My BLL is a separate project that is part of the same solution that includes the web app (there are other class library assemblies in my solution too).
The root directory for my BLL DLL is a peer to the root for the web app.
For what it's worth I know that the App_LocalResources dir works since I refer to Resources.<x>.<y> in some my web app's aspx.cs files.
I just discovered a way to 'embed' a resource file (seems like it must be named Resources.resx) into the class library assembly (in the assembly properties resource table). And I AM able to access the resources using the Resources.<resource name> thing.
However, this is not exactly what I need. I need to create multiple versions for the various cultures I am supporting and I don't seem to be able to embed more that ONE embedded resource file.
Jan 27, 2006 09:49 PM|StrongTypes|LINK
Have you tried using a ResourceManager?
Resource Manager and ASP.NET
Jan 27, 2006 10:02 PM|e2canoe|LINK
No. I was so looking forward to the strong typing that I haven't.
I'm going to keep trying Thanks for the help.
Jan 27, 2006 10:10 PM|StrongTypes|LINK
I really haven't done much with resources in .NET 2.0, but I'm sure it's possible to have strongly typed resources for your situation.
Localization in ASP.NET 2.0
Jan 27, 2006 11:56 PM|e2canoe|LINK
Ya, I gotta believe that it is possible. The problem as I see it is that the facility in VS.2005 for auto-generating the class that allows me to access resources using "Resources" class members seems to be tied to the existance of the special "App_GlobalResources"
and "App_LocalResources" directories. And since these directories only exist in web apps, they fall outside of the scope of my solution's class library assemblies.
All the resources on the web and MSDN assume that one is associating resources with a web app. In my case it is a class library.
Anybody got any ideas on how to get the benefits of the "Resources" class wrapping of resources (and the resulting intellisense) for multiple resources files (multiple cultures) associated with a class library assembly in .NET 2.0?
I'm really stumped on this one!