Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / IDE / November 2005

Tip: Looking for answers? Try searching our database.

Visual Studio 2005 using 1.1 Libraries

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MICHAEL CARR - 02 Nov 2005 00:20 GMT
After firing up VS2005, I loaded an application that was originally written with 1.1. In this I had a lot of references that uses:

System.Configuration.ConfigurationSettings.AppSettings[]

I see the Warning:
Warning 5 'System.Configuration.ConfigurationSettings.AppSettings' is obsolete: 'This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings

However, when trying to use the new ConfigurationManager, it does not display with Intellisense and I gives an error:

Error 5 The type or namespace name 'ConfigurationManager' does not exist in the namespace 'System.Configuration' (are you missing an assembly reference?)

I have also tried to reference the .NET 2.0 System.Configuration dll to no avail.

If I reference the System.configuration dll, then use:
ConfigurationManager.AppSettings[""]

I get an error:
Error 2 The name 'ConfigurationManager' does not exist in the current context

It looks like the IDE is unable to find the .NET 2.0 assemblies.

Signature

MICHAEL CARR

MICHAEL CARR - 02 Nov 2005 00:46 GMT
Using object viewer I see that:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll
has a System.Configuration library

There is also a
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.configuration.dll

 After firing up VS2005, I loaded an application that was originally written with 1.1. In this I had a lot of references that uses:

 System.Configuration.ConfigurationSettings.AppSettings[]

 I see the Warning:
 Warning 5 'System.Configuration.ConfigurationSettings.AppSettings' is obsolete: 'This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings

 However, when trying to use the new ConfigurationManager, it does not display with Intellisense and I gives an error:

 Error 5 The type or namespace name 'ConfigurationManager' does not exist in the namespace 'System.Configuration' (are you missing an assembly reference?)

 I have also tried to reference the .NET 2.0 System.Configuration dll to no avail.

 If I reference the System.configuration dll, then use:
 ConfigurationManager.AppSettings[""]

 I get an error:
 Error 2 The name 'ConfigurationManager' does not exist in the current context

 It looks like the IDE is unable to find the .NET 2.0 assemblies.

 --
 MICHAEL CARR
"Jeffrey Tan[MSFT]" - 02 Nov 2005 04:16 GMT
Hi MICHAEL,

Yes, you are right, but this is not a problem. For classes in
System.Configuration namespace, part of the classes reside in System.dll,
while the others reside in System.Configuration.dll, in .Net, assembly will
not go corresponding with the assembly dll.

Specificly, for System.Configuration.ConfigurationManager class, it only
resides in System.Configuration.dll, so we should refer this assembly.

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

MICHAEL CARR - 02 Nov 2005 22:25 GMT
Ok, I reinstalled everything and it looks like it does work. Thanks for the
responses.

Signature

MICHAEL CARR

> Hi MICHAEL,
>
[quoted text clipped - 13 lines]
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
"Jeffrey Tan[MSFT]" - 03 Nov 2005 08:00 GMT
Cool, I am glad it works fine now. If you need further help, please feel
free to tell me, thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

MICHAEL CARR - 02 Nov 2005 01:19 GMT
I had installed the .NET 2.0 Redistributable, then VS2005. I have uninstalled everything and I am going to try install only VS2005 and see what the outcome is.

 After firing up VS2005, I loaded an application that was originally written with 1.1. In this I had a lot of references that uses:

 System.Configuration.ConfigurationSettings.AppSettings[]

 I see the Warning:
 Warning 5 'System.Configuration.ConfigurationSettings.AppSettings' is obsolete: 'This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings

 However, when trying to use the new ConfigurationManager, it does not display with Intellisense and I gives an error:

 Error 5 The type or namespace name 'ConfigurationManager' does not exist in the namespace 'System.Configuration' (are you missing an assembly reference?)

 I have also tried to reference the .NET 2.0 System.Configuration dll to no avail.

 If I reference the System.configuration dll, then use:
 ConfigurationManager.AppSettings[""]

 I get an error:
 Error 2 The name 'ConfigurationManager' does not exist in the current context

 It looks like the IDE is unable to find the .NET 2.0 assemblies.

 --
 MICHAEL CARR
"Jeffrey Tan[MSFT]" - 02 Nov 2005 04:09 GMT
Hi MICHAEL,

Thanks for your post.

I am not sure what wrong with your project. After adding
System.Configuration.dll, have you added the following using statement?
using System.Configuration;

In my test sample, I added the reference to System.Configuration.dll, then
adding the using System.Configuration;. I can get the "appSettings" section
in app.config with the code below:
private void Form1_Load(object sender, EventArgs e)
{
   // Get the appSettings.
   NameValueCollection appSettings =
        ConfigurationManager.AppSettings;

   // Get the collection enumerator.
   IEnumerator appSettingsEnum =
       appSettings.Keys.GetEnumerator();

   // Loop through the collection and
   // display the appSettings key, value pairs.
   int i = 0;
   Console.WriteLine("App settings.");
   while (appSettingsEnum.MoveNext())
   {
       string key = appSettings.Keys[i];
       Console.WriteLine("Name: {0} Value: {1}",
       key, appSettings[key]);
       i += 1;
   }
}

My testing app.config file is:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
 <configSections>
   <section name="CustomSection"
      type="Samples.Config.CustomSection,
        ConfigurationManager,
        Version=1.0.0.0,
        Culture=neutralPublicKeyToken=null"
        allowDefinition="Everywhere"
        allowExeDefinition="MachineToApplication"
        restartOnExternalChanges="true" />
 </configSections>
 <connectionStrings>
   <add name="ConnStr1"
     connectionString="LocalSqlServer: data source=127.0.0.1;Integrated
Security=SSPI;Initial Catalog=aspnetdb"
     providerName="System.Data.SqlClient" />
   <add name="ConnStr2"
     connectionString="LocalSqlServer: data source=127.0.0.1;Integrated
Security=SSPI;Initial Catalog=aspnetdb"
     providerName="System.Data.SqlClient" />
 </connectionStrings>
 <appSettings>
   <add key="AppSetting0"
     value="Monday, February 28, 2005 1:27:59 PM" />
   <add key="AppSetting1"
     value="Monday, February 28, 2005 1:36:40 PM" />
 </appSettings>
 <CustomSection fileName="default.txt" maxUsers="1000"
    maxIdleTime="00:10:00" />
</configuration>

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Cowboy (Gregory A. Beamer) - 02 Nov 2005 20:01 GMT
You need to ensure there is a reference to System.Configuration.dll.  Beyond that, it should work.

Where are you pulling the app setttings from? Your codeBehind, another class, another project, etc.?

Signature

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***********************************************
Think Outside the Box!
***********************************************

 After firing up VS2005, I loaded an application that was originally written with 1.1. In this I had a lot of references that uses:

 System.Configuration.ConfigurationSettings.AppSettings[]

 I see the Warning:
 Warning 5 'System.Configuration.ConfigurationSettings.AppSettings' is obsolete: 'This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings

 However, when trying to use the new ConfigurationManager, it does not display with Intellisense and I gives an error:

 Error 5 The type or namespace name 'ConfigurationManager' does not exist in the namespace 'System.Configuration' (are you missing an assembly reference?)

 I have also tried to reference the .NET 2.0 System.Configuration dll to no avail.

 If I reference the System.configuration dll, then use:
 ConfigurationManager.AppSettings[""]

 I get an error:
 Error 2 The name 'ConfigurationManager' does not exist in the current context

 It looks like the IDE is unable to find the .NET 2.0 assemblies.

 --
 MICHAEL CARR

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.