Last post Jul 25, 2008 11:03 AM by G0ggy
Jul 25, 2008 10:14 AM|everett31|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 10:23 AM|Jeev|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
Jul 25, 2008 10:23 AM|Som Nath Shukla|LINK
use System.Web.Configuration. namespace.
Jul 25, 2008 10:24 AM|G0ggy|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 10:25 AM|keyrav|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 10:32 AM|santa_1975|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 11:02 AM|everett31|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 11:03 AM|G0ggy|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"