?
Solved

string reference not set to an instance of a string

Posted on 2006-04-13
8
Medium Priority
?
2,417 Views
Last Modified: 2007-12-19

CultureInfo DefaultCulture = new CultureInfo("en-gb");
DefaultCulture = new CultureInfo(System.Configuration.ConfigurationManager.AppSettings["en-gb"]);

String reference not set to an instance of a string
Parameter name :name
0
Comment
Question by:PradeepYadhav
  • 2
  • 2
5 Comments
 
LVL 12

Expert Comment

by:AGBrown
ID: 16447466
What is the content of your .config file? In particular what is the full contents of the line
<add key ="en-gb" .....>
0
 

Author Comment

by:PradeepYadhav
ID: 16447505
<add key="TestCulture" value="en-gb"/>
0
 

Author Comment

by:PradeepYadhav
ID: 16447512
It is

<add key="DefaultCulture" value="en-gb"/>
0
 
LVL 12

Accepted Solution

by:
AGBrown earned 252 total points
ID: 16447513
Ah, in which case try:
DefaultCulture = new CultureInfo(System.Configuration.ConfigurationManager.AppSettings["TestCulture"]);
0
 
LVL 11

Assisted Solution

by:vo1d
vo1d earned 248 total points
ID: 16448375
i agree to agbrown.
but you should not make this call:
DefaultCulture = new CultureInfo(System.Configuration.ConfigurationManager.AppSettings["TestCulture"]);

you should evaluate your constructor arguments before using them:

CultureInfo DefaultCulture = null;
string testValue = System.Configuration.ConfigurationManager.AppSettings["TestCulture"];
if(testValue != null)
{
  DefaultCulture = new CultureInfo(testValue);
}
else
{
 //handle the uninitialized cultureinfo
}

regards, vo1d
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Loops Section Overview
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question