ConfigurationSettings.GetConfig difference between .NET 1.1 and .NET 2.0 beta 2

P

Predrag Stanar

This piece of code works flawlessly in .NET 1.1 but fails in .NET 2.0 beta 2
with following exception:

Unhandled Exception: System.Configuration.ConfigurationErrorsException: An error
occurred creating the configuration section handler for customGroup/customSecti
on: Could not load type 'System.Configuration.NameValueSectionHandler' from asse
mbly 'System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03
f5f7f11d50a3a'. (C:\Temp\TestApp\Test.exe.config line 5) ---> System
..TypeLoadException: Could not load type 'System.Configuration.NameValueSectionHa
ndler' from assembly 'System.Configuration, Version=2.0.0.0, Culture=neutral, Pu
blicKeyToken=b03f5f7f11d50a3a'.

Test.cs
-------
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Configuration;

namespace TestNs
{
class Test
{
[STAThread]
static void Main(string[] args)
{
NameValueCollection keyValuePairs = ConfigurationSettings.GetConfig(
"customGroup/customSection" ) as NameValueCollection;
if ( null != keyValuePairs )
{
IEnumerator enumKeys = keyValuePairs.GetEnumerator();
while ( enumKeys.MoveNext() )
{
string key = (string) enumKeys.Current;
Console.WriteLine( "Key: {0}, Value: {1}", key,
keyValuePairs.Get( key ) );
}
}
}
}
}

Test.exe.config
---------------
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="customGroup">
<section name="customSection"
type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v2.0.50215"/>
<supportedRuntime version="v1.1.4322"/>
</startup>
<appSettings>
</appSettings>
<customGroup>
<customSection>
<add key="key1" value="value1"/>
<add key="key2" value="value2"/>
<add key="key3" value="value3"/>
</customSection>
</customGroup>
</configuration>

I tried to add assembly (System) in the customSection's type, but makes no
difference. I do understand that GetConfig() is deprecated, but I have to
maintain compatibility with .NET 1.1 for a while. And beside, even deprecated,
it still should work, shouldn't it?
 
K

Kevin Yu [MSFT]

Hi Predrag,

We have reviewed this issue and are currently researching on it. We will
update you ASAP. Thanks for your patience!

For .NET framework 2.0 issues, besides posting here, you can also try to
post in the following forum. It is dedicated for .NET framework 2.0 issues.

http://forums.microsoft.com/msdn/default.aspx

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
P

Peter Huang [MSFT]

Hi


Since VS.NET 2005(Whidbey) has not been released, it is still in the beta
test period, so the behavior may vary in the finaly release version.
So far for Whidbey issue, I think you may try to post in vs2005 forum.
http://lab.msdn.microsoft.com/vs2005/community/forums/default.aspx

Sorry for the inconvenience.

Best regards,

Peter Huang
Microsoft Online Partner Support

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top