Getting Null Reference Exception when having two config section

  • Thread starter Thread starter vasu devan via DotNetMonster.com
  • Start date Start date
V

vasu devan via DotNetMonster.com

Hi,

I am two config section with same config section handler like follow.
<section name="Myformatters"
type="MyFramework.Configuration.FileHandlers.MyConfigFileHandler,
MyFramework"/>
<section name="Myserviceproxies"
type=MyFramework.Configuration.FileHandlers.MyConfigFileHandler,
MyFramework"/>

And my sections looks like the following,

<Myserviceproxies>
<proxies>
<proxy name="1" type="MyServiceProxy.Class1,MyServiceProxy"/>
</proxies>
</Myserviceproxies>
<Myformatters>
<formatters>
<formatter name="1"type="MyServiceProxy.Class1,VinServiceProxy"/>
</formatters>
</Myformatters>

When I am trying to access the config settings through
ConfigurationSettings.GetConfig method passing the config section name, it
is working fine for Myserviceproxies config section. But for the second
config section Myformatters the method returns null. Implementatin of
IConfigurationSectionHandler.Create method is not called for Myformatters
section. For Myserviceproxies everything is working fine.

What could be the problem?

with regds,
Vasu
 
Vasu,

Just by looking at your xml I noticed that the "<formatter>" element has a
"name" attribute and a "type" attribute, but you seem to be missing a space
between them. try adding a space and see if your code works.

Instead of:
<Myformatters>
<formatters>
<formatter name="1"type="MyServiceProxy.Class1,VinServiceProxy"/>
</formatters>
</Myformatters>

Try:
<Myformatters>
<formatters>
<formatter name="1" type="MyServiceProxy.Class1,VinServiceProxy"/>
</formatters>
</Myformatters>
 
Jorge,

I tried that. Still I am getting the same error message.For me it seems the
problem lies in ConfigurationSettings class. But I am not sure. This
behaviour due to the caching nature of ConfigurationSettings class.

with regds,
Vasu
 
Back
Top