Wrox Programmer Forums
|
BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio
This is the forum to discuss the Wrox book ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solution by Vincent Varallo; ISBN: 9780470396865
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 16th, 2009, 04:29 PM
Authorized User
 
Join Date: Apr 2009
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default ConfigurationManager:object not set to a reference

Hi,

My DBHelper is not working I get "object not set to a reference" error. All my references to System.configuration.dll and imports system.Configuration are Ok as well as the
connectionString name etc.. in the config file

Investigation has so far shown that the connectionStrings section in the app.config
cannot be seen by configurationManager.
i.e. ConfigurationManager.ConnectionStrings("MyConnString") is Null or Nothing ( I am usign vb.net)

I have also found out that the configuration manager gets its info from IIS full stop. If the connection string in IIS is removed I get an error
I put <clear/> in the app.config file to no avail

Is there a way to tell configuration manager which app.config to look at ? ( I only have one of course)

Any idea is appreciated

Thanks

Last edited by luckystar; May 16th, 2009 at 06:33 PM.. Reason: completed
 
Old May 18th, 2009, 04:25 PM
Authorized User
 
Join Date: Apr 2009
Posts: 41
Thanks: 1
Thanked 2 Times in 2 Posts
Default

Check to see if the connection string is defined elsewhere in the project (though it doesn't sound like it based on your description).

In the ORM designer, look in the property pane and expand the Connection node to see what values (if any) are present.

In the Settings tab of the Property page for the DAL project see if there's a connection string entry (this can also be accessed by opening the Properties->Settings.settings->Settings.Designer.cs file from the solution).

Can you post the relevant parts of your code? It could be something as simple as a typo as well.

Tim
 
Old May 25th, 2009, 05:03 PM
Authorized User
 
Join Date: Apr 2009
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Thanks Tim, I checked the connection node in the ORM designer and indeed the correct connection
string is present. I also treble checked for typo the software works when there is an IIS connection string configured.

I am using the connection string name generated by the ORM in the app.config file.

The issue here is that no matter what I do the configuration manager seems to read the IIS connection
string settings. If I remove the IIS connection string then I get the the error.

So how can one configure the configuration manager to look at the app.config file .

regards
 
Old May 28th, 2009, 02:08 PM
Authorized User
 
Join Date: Apr 2009
Posts: 41
Thanks: 1
Thanked 2 Times in 2 Posts
Default

When you say IIS connection string, what do you mean?

Can you post your app.config? I'm not sure why you're encountering this error. I wonder if it's IIS-related and not necessarily .NET?
 
Old June 1st, 2009, 12:31 PM
Authorized User
 
Join Date: Apr 2009
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

It is all ok now, I expected the configuration manager to read from the app.config. That is not so. So I created the connectionstring in the web.config and it seems to work.

As to IIS if you go to the connectionstring tab you can also set connection strings and if the configuration manager does not find the connectionstring name (key) in the web.config file
it looks at the IIS connection string settings.

regards





Similar Threads
Thread Thread Starter Forum Replies Last Post
Object Reference not set ZeroFactorial BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio 4 April 9th, 2009 02:06 AM
Object reference not set to an instance of object iceman90289 ASP.NET 3.5 Basics 1 March 1st, 2009 05:13 AM
object reference not set to instant of an object shahidrasul ASP.NET 2.0 Basics 1 September 5th, 2008 02:01 PM
Object Reference not set to an instance of object srinivas_chakka ASP.NET 1.0 and 1.1 Professional 0 February 8th, 2006 11:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.