By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,905 Members | 1,585 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,905 IT Pros & Developers. It's quick & easy.

Error trying to read Custom Configuration Sections

P: n/a
Dear all,
I have created personalized configuration sections in my web project
following the instructions described in this page
http://msdn.microsoft.com/library/de...onSections.asp

The problem is that I using the same code and I get the error "Object
reference not set to an instance of an object" in the line where I try to
read the first parameter (in the page attached : value1 =
CType(sampleTable("setting1"), String)).

I have made some investigations and this error occurs when you don't create
the object with new. The problem is that in this case is not possible because
IDictionary is an interfaz.

I have also investigated that it could be a version problem, here you can
find the versions I'm using Microsoft .NET Framework, Version:1.1.4322.573
ASP.NET Version:1.1.4322.573

can you help me?

Thank you very much.

Regards,
Paloma GarcÃ*a.
Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
> The problem is that I using the same code and I get the error "Object
reference not set to an instance of an object" in the line where I try to
read the first parameter (in the page attached : value1 =
CType(sampleTable("setting1"), String)).
Did you create a custom Configuration Section in your web.config or
app.config file? Did you create it as a SingleTagSectionHandler type? Did
you declare it correctly in the <configSections> section of the config file?
Did you put the actual section into the config file, in the proper location?
Did you instantiate the IDictionary, as per the sample, using the static
ConfigurationSettings.GetConfig() method prior to trying to get data out of
it?
I have made some investigations and this error occurs when you don't
create
the object with new. The problem is that in this case is not possible
because
IDictionary is an interfaz.
Create WHAT object? The object that you have cast as an IDictionary is
returned by the ConfigurationSettings.GetConfig() method. You are simply
casting it as an IDictionary type (that is, a class that implements
IDictionary). When you create a custom Section of type
SingleTagSectionHandler, it creates an object of type IDictionary. You can
get an instance of the object without using the New operator. You can get an
instance of an object as the return value of a function (such as
ConfigurationSettings.GetConfig()). The only reason that such a function
would return Nothing is if an exception occurred in the function, or
possibly in this case, if the function didn't find what you told it to find.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
I'd rather be a hammer than a nail.

"Paloma García" <Pa*********@discussions.microsoft.com> wrote in message
news:25**********************************@microsof t.com... Dear all,
I have created personalized configuration sections in my web project
following the instructions described in this page
http://msdn.microsoft.com/library/de...onSections.asp

The problem is that I using the same code and I get the error "Object
reference not set to an instance of an object" in the line where I try to
read the first parameter (in the page attached : value1 =
CType(sampleTable("setting1"), String)).

I have made some investigations and this error occurs when you don't
create
the object with new. The problem is that in this case is not possible
because
IDictionary is an interfaz.

I have also investigated that it could be a version problem, here you can
find the versions I'm using Microsoft .NET Framework, Version:1.1.4322.573
ASP.NET Version:1.1.4322.573

can you help me?

Thank you very much.

Regards,
Paloma García.

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.