473,396 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

using resource file ...

Hi all,

I m using asp.net 2.0 version and want to retrieve the particular string
from resource file dynamically... Following is the my code ... but in this
every time I get exception that resource key not found... ... might be
possible as i think that resource file which is being loaded is not fund ...
plz suggest me how to find the base name of project so that the resource file
will be loaded .....

using System;
using System.Resources;
using System.Reflection;

namespace ResourcesDemo
{
/// <summary>
/// Class for resource retrival
/// </summary>
public class ResourceText
{
private ResourceText()
{}

private static ResourceManager _resourceManager;

//Following method will be called from Global.asax Application_Start

public static void InitializeResources() //
{
string gg = Assembly.GetExecutingAssembly().FullName;
Assembly assembly = Assembly.GetExecutingAssembly();
_resourceManager = new ResourceManager("ResourcesDemo.TextRes",
assembly);
_resourceManager.IgnoreCase = true;
}

public static string GetString(string key)
{
string gg = Assembly.GetExecutingAssembly().ToString();
try
{
string s = _resourceManager.GetString( key );
if( null == s ) throw(new Exception());
return s;
}
catch
{
//for resource key not found
return String.Format("[?:{0}]", key);
}
}
}
}

// resource schema...
....
<data name="EMPLOYEE">
<value>Employee</value>
</data>
<data name="DELETE_EMPLOYEE_CONFIRMATION">
<value>Are you sure you want to delete this employee?
Doesn't matter it will be deleted any way...</value>
</data>
....
Reply soon …
Thanks for giving me your time

Jun 12 '07 #1
0 1241

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ben Jones | last post by:
Hi there, I am looking into the ease of implementing the localization/globalization features of .NET using C#. I have a test app which creates a ResourceManager and attempts to load a resource...
1
by: Bilal Farooq via .NET 247 | last post by:
(Type your message here) -------------------------------- From: Bilal Farooq Hi, I have following requirements to achieve: I have some images andI am adding them as a resource to a dll....
3
by: J.Marsch | last post by:
Hello all: I am trying to build a resource dll that will house icons, and I'm afraid that I'm not having much luck reading it. Can you lend hand (or just point me to a good primer). Here's...
5
by: Mukesh | last post by:
Hi i want to use AJAX.net in my Existing Application I have already installed the ajax .net ..net 3.0 and using VS 2005 in the old application i have added a new web form then script manager...
2
by: Daniel | last post by:
I am just investigating on .resx and .resource files using asp.net. I am attempting to develop a webpage in Dreamweaver on an asp.net webserver. As i read around the net, using a .resource file...
0
by: =?Utf-8?B?cHJhc2hhbnQga3VtYXIgc3JpdmFzdGF2YQ==?= | last post by:
Hi all, I m using asp.net 2.0 version and want to retrieve the particular string from resource file dynamically... Following is the my code ... but in this every time I get exception that...
2
by: Andrus | last post by:
I have resource files in different languages created by VCS 2005 Express. I want to use those files to translate reports at runtime. I have text to be translated as string. I think I need to...
2
by: Nathan Sokalski | last post by:
I am attempting to create icons for controls I have created using VB.NET by using the System.Drawing.ToolboxBitmap attribute. I have managed to do this in C# by specifying the path to the *.ico...
2
by: yxq | last post by:
I want to add some elements to a XML file using XmlDocument, how to do? thank you very much. The original XML file like: //////////////////////////////////////////////////////// <?xml...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.