Friday, June 20, 2008

Reading resources from resource dll of another application

Copy the Application Dll and Resource dll to one folder.

in the code

Assembly assL = Assembly.LoadFrom(@"C:\Personal\CERT\70-528\MGohil.Services.Authentication.dll");

//here ApplicationTokens is the resource file i.e. ApplicationTokens.resx or ApplicationTokens.en-US.resx
ResourceManager rm = new ResourceManager("MGohil.Services.Authentication.ApplicationTokens", assL);

string t = rm.GetString("XYZ_Key");

Wednesday, June 18, 2008

Rename database table column SQL Server

Execute below statemnet in SQL analyzer and it will rename the column name.

exec sp_rename 'DBO.Customers.CompanyName', 'CorporateName', 'COLUMN'

Wednesday, June 11, 2008

ASP.NET Control Access Key, AssociatedControlID and Underline single character for access key

Create a local resource file for the corresponding page.

Make an entry in the resource file Name = lblUserNameResource1.Text
and Value = <U>U</U>sername:

and in the ASP.net page for the control use the meta tag instead of text
i.e. meta:resourcekey="lblUserNameResource1"

Thursday, June 5, 2008

Reading from Resources.dll in ASP.NET

Assembly ass = Assembly.LoadFrom(@"C:\CERT\70-528\TestAssembly\MGohil.Services.Authentication.resources.dll");
string strManRes = ass.GetManifestResourceNames()[0]; // use this to get the manifest resource, in next line
Stream str = ass.GetManifestResourceStream("MGohil.Services.Authentication.ApplicationTokens.en-US.resources");


ResourceReader r = new ResourceReader(str);
IDictionaryEnumerator id = r.GetEnumerator();
while (id.MoveNext())
{
Console.WriteLine(id.Key + " - " + id.Value);
}