Last post Jul 25, 2008 04:03 PM by G0ggy
Jul 25, 2008 03:14 PM|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 03:23 PM|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 03:23 PM|Som Nath Shukla|LINK
use System.Web.Configuration. namespace.
Jul 25, 2008 03:24 PM|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 03:25 PM|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 03:32 PM|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 04:02 PM|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 04:03 PM|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"