Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jul 25, 2008 03:03 PM by G0ggy
Jul 25, 2008 02:14 PM|LINK
How do I include this in a database component? I'm following along with Beginning ASP.net 2.0 C# by Apress. I've pasted in the code from the exercise below. I can complete the project fine using a class , but not as a stand alone component. I get the
following error: " The type or namespace "configuration" does not exist." I'm sure I'm missing something simple here, but it doesn't appear to me that a custom class library has a web.config, so I need some more code to grab the value from a web.config once
the data object is referenced in my application. Thanks in advance for any insight.
Jul 25, 2008 02:23 PM|LINK
To include it in a database component add a reference to system.Configuration dll to your project if it does not already exist and then replace WebconfigurationManager with just ConfigurationManager
use System.Web.Configuration. namespace.
Jul 25, 2008 02:24 PM|LINK
Is System.Web in your web references? (Website - Add Reference), if not you'll need to re-install .NET 2.0, or try adding the reference it's located in C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.configuration.dll
Personally I would re-install/repair .NET.
Jul 25, 2008 02:25 PM|LINK
Are you trying to access connection string in your class file ?
Try to access it like this.
ConnectionStringSettings s = ConfigurationManager.ConnectionStrings["Connstr"];
Jul 25, 2008 02:32 PM|LINK
Did you add a reference to System.Configuration?If not,
1. Right click on the References in the object explorer and choose "Add Reference".
2. From the .NET tab choose System.Configuration and click ok.
This should work.
Jul 25, 2008 03:02 PM|LINK
Thanks for the help. It works with ConfigurationMananger or WebConfigurationManager if the reference is added to the project. I figured it would be simple but sometimes I want to kick myself in the ***. Thanks again for the responses. This forum is
Jul 25, 2008 03:03 PM|LINK
"Is System.Web in your web references? (Website - Add Reference), if not you'll need to re-install .NET 2.0, or try adding the reference it's located in C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.configuration.dll"