Question How to access Resource file from a Class Library ?

paulnamroud

Member
Joined
Nov 1, 2006
Messages
5
Programming Experience
5-10
Hello,

I'm building a generic Class Library that I will use it in all my projects.

However, I want to know how can I access Resource file from a Class Library ?

I will appreciate if you can send me a code sample!

Thank you for your help

Paul
 
Last edited:
Open the project properties pages and select Resources page, set Access Modifier to Public.
In code access the library resource by qualifying the root namespace to My.Resources, eg ClassLibrary1.My.Resources.something.
 
Thank you John it works by doing the following: LibAEM.Properties.Resources.ResourceManager.GetString("RecordType_Missing").ToString() where LibAEM is the name of my Class Library.

I have already worked on a Website Project where we can create our classes under App_Code Folder (e.g. App_Code/CCustomer.cs), and then we can create all related Resouces File under App_GlobalResources (e.g. App_GlobalResources/CCustmomers.resx or App_GlobalResources/CCustmomers.fr.resx ... ) . And we can acces the resouces files by doing the following: Resources.CCustomers.FirstName_Missing.ToString()


So I would like to know if there's a way to have a resource file for each class inside my Class Library or something similar to what we have in a Website Project ?

Thank you
 
Last edited:
Back
Top