By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,214 Members | 2,072 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,214 IT Pros & Developers. It's quick & easy.

using resource file ...

P: n/a
Hi all,

I m using 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",
_resourceManager.IgnoreCase = true;

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

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

Jun 12 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.