Looks like you may be new to the .NET world? If so, then welcome aboard. You may have better luck in this group in the future if you're more descriptive of your errors and how you attempted to solve them.
In this case, a "NullReferenceException" is very common and is actually pretty easy to debug. 99% of the time, you've got a "dot" somewhere on an object that is null. In your case, ConfigurationManager.ConnectionStrings["appConnection"] is probably null, so calling ".ConnectionString" on it throws the exception. You should verify that the key actually exists in your config file, and also wrap your code in a way that checks to ensure that it's not null before calling any methods or parameters on it. On Dec 22, 7:30 am, "hirendra singh" <[email protected]> wrote: > i am find some error in my server runing code! how to finD best solution > > string conn = > ConfigurationManager.ConnectionStrings["appConnection"].ConnectionString; > > pllz any one can solve my problem > > thanks > > Server Error in '/' Application. > ------------------------------ > *Object reference not set to an instance of an object.* * Description: *An > unhandled exception occurred during the execution of the current web > request. Please review the stack trace for more information about the error > and where it originated in the code. > > * Exception Details: *System.NullReferenceException: Object reference not > set to an instance of an object. > > *Source Error:* > > Line 14: { > Line 15: SqlConnection con = new SqlConnection(); > Line 16: string conn = > ConfigurationManager.ConnectionStrings["appConnection"].ConnectionString; > Line 17: protected void Page_Load(object sender, EventArgs e) > Line 18: { > > * Source File: * c:\inetpub\vhosts\vdnext.com\httpdocs\Default.aspx.cs* > Line: * 16 > > *Stack Trace:* > > [NullReferenceException: Object reference not set to an instance of > an object.] > DashbordHome..ctor() in > c:\inetpub\vhosts\vdnext.com\httpdocs\Default.aspx.cs:16 > ASP.default_aspx..ctor() in > c:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET > Files\root\76234fdf\841788f2\App_Web_prgugeem.0.cs:0 > __ASP.FastObjectFactory_app_web_prgugeem.Create_ASP_default_aspx() > in c:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET > Files\root\76234fdf\841788f2\App_Web_prgugeem.4.cs:0 > System.Web.Compilation.BuildResultCompiledType.CreateInstance() +32 > > System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath > virtualPath, Type requiredBaseType, HttpContext context, Boolean > allowCrossApp, Boolean noAssert) +119 > System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext > context, String requestType, VirtualPath virtualPath, String > physicalPath) +33 > > System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext > context, String requestType, VirtualPath virtualPath, String > physicalPath) +40 > System.Web.HttpApplication.MapHttpHandler(HttpContext context, > String requestType, VirtualPath path, String pathTranslated, Boolean > useAppConfig) +160 > > System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() > +93 > System.Web.HttpApplication.ExecuteStep(IExecutionStep step, > Boolean& completedSynchronously) +155 > > ------------------------------ > *Version Information:* Microsoft .NET Framework Version:2.0.50727.3053; > ASP.NET Version:2.0.50727.3053 > -- > A Door knocks twice. insider asks--who is there... ans was : its OPPOTUNITY" > insider tels ,you are wrong becouse oppotunity never knocks twice > रात यों कहने लगा मुझसे गगन का चाँद, > आदमी भी क्या अनोखा जीव होता है! > ,उलझनें अपनी बनाकर आप ही फँसता > और फिर बेचैन हो जगता, न सोता है।
