Last post Aug 11, 2010 11:37 PM by jkirkerx
Feb 11, 2008 04:05 AM|robi|LINK
Hi i created a class library that will represent a custom control.
I want to have a resource resx file inside the class library, and i want to access it from the custom control's class, how can i do that?
All the examples i've seen are explaining how to embed js, css or images within a dll, but not how to access a .resx resource file.
Feb 11, 2008 06:41 AM|The Eagle|LINK
You go to the "Design" view of your custom control, go to "Tools", click on "Generate Local Resource". This will generate for you a resx file for your custom control.
Feb 11, 2008 07:07 AM|robi|LINK
I want my resource resx file to be a part of my class library. Not after the custom control has already been deployed.
I want it to be embeded in the dll.
Oct 01, 2008 09:28 PM|ambic|LINK
I have a similar issue. I have a series of 3 components - "StudentAddress", "StudentPhoneNumber" and "StudentPredictedTimeTable". Each of these are in a project called Components relating to the project they are part of. They are components as they are
used multiple times throughout my project. Each component is saved in a CS file that my ASP.net front end later implements.
class StudentAddress :
Now, I have added an resx file to the Components project, but as yet cant see how to reference it at this level. I get all kinds of errors about "Could not find any resources appropriate for the specified culture
(or the neutral culture) on disk." Which I presume means the software implementing the control is looking for the resource file at its own end.
Feb 18, 2010 09:52 AM|matt_lethargic|LINK
I've just come across this problem while building a control also.
Anyone got any ideas?
Feb 23, 2010 07:41 PM|CoolControls|LINK
Maybe I'm missing something here, but from what I understand the situation is as follow:
Now you want to access the resource from one of the controls?
Set the Build Action property for YourResource.resx to Embedded Resource and within your code you can use:
ResourceManager resMngr = new ResourceManager(typeof(YourResource));
object obj = resMngr.GetObject("key");
Or do you mean something else?
Aug 11, 2010 11:37 PM|jkirkerx|LINK
Your not really accesssing the resx file in a sense, but more like accessing the reader object of where the values are stored.
You can populate the strings in the property panel of the project name at the top of solution explorer by right clicking, and navigating to resources.
To call the resource
Dim rm As ResourceManager = New ResourceManager("RootNameSpace", Assembly.GetExecutingAssembly())
Dim Product_Credential_Key As String = rm.GetString("Global_Product_CredentialKey") - Resources Name Value
You could probably reverse the process to write strings to the file, but I think they are read only.
GetObject is a metaphore, not to be taken literally - GetBoolean, GetString