VB.NET - Explain how to retrieve resources using ResourceManager class.

Explain how to retrieve resources using ResourceManager class.

Use ResourceManager class to retrieve resources that exist in an assembly. Steps to do so are:

1. Create a reference to the assembly that has the resources.
2. Create an instance of ResourceManager.
3. Specify the base name of the resource file and provide the reference to the assembly that contains it.
4. Use the ResouceManager's GetObject or GetString method to retrive the resource.

Example:
Dim assembly As System.Reflection.Assembly
assembly = Me.GetType.Assembly
Dim myOtherAssembly As System.Reflection.Assembly
myOtherAssembly = System.Reflection.Assembly.Load("ResourceAssembly")

' Creates the ResourceManager'.

Dim resourceManager As New _ System.Resources.ResourceManager("ResourceNamespace.myResources", _assembly)

Dim resString As System.String
Dim resObj As System.Drawing.Image
resString = resourceManager.GetString("StringResource")
resObj = CType(resourceManager.GetObject("ImageResource"), _System.Drawing.Image)
VB.NET - How do you install assembly to the Global Assembly Cache?
How do you install assembly to the Global Assembly Cache? - Using Gacutil.exe:eg: gacutil -i MyLibrary.dll.....
VB.NET - Explain how managed code slower than unmanaged code
Explain how managed code slower than unmanaged code - Managed code not always is slower than unmanaged code.......
What are the options for stepping through code?
Options for stepping through code - Show next statement - step into, step over, step out.....
Post your comment