Monday, March 26, 2012

Web.config not being read.

I'm having a problem deploying my ASP.NET application to a WIN2k server.
(IIS5 .NET 1.1)

When I try to access ConfigurationSettings.AppSettings("WhateverValue") I
get an "Object reference not set to an instance of an object." message

I thought this may have been to do with Virtual Directory settings but I've
got the folder set as an application in IIS and asp.net is installed and
working. My web.config file is Not Marked read-only and I can't see any
other problems with the setup. pages that do not attempt to read settings
from the web.config work correctly.

Has anyone else come across this problem, and if so, how did you fix it?

best regards,

Chris.Have you put your <appSettings></appSettings> outside of the <system.web
<configuration
<appSettings>
<add key="WhateverValue" value="1234" />
</appSettings
<system.web>
...
</system.web>
</configuration
Also web.config is case sensitive, but I don't think that matters as far as
attribute values.

HTH,
--Michael

"Chris V" <varleycNOSPAM@.gaelREMOVETHISquality.co.uk> wrote in message
news:40165cab@.news.star.co.uk...
> I'm having a problem deploying my ASP.NET application to a WIN2k server.
> (IIS5 .NET 1.1)
> When I try to access ConfigurationSettings.AppSettings("WhateverValue") I
> get an "Object reference not set to an instance of an object." message
> I thought this may have been to do with Virtual Directory settings but
I've
> got the folder set as an application in IIS and asp.net is installed and
> working. My web.config file is Not Marked read-only and I can't see any
> other problems with the setup. pages that do not attempt to read settings
> from the web.config work correctly.
> Has anyone else come across this problem, and if so, how did you fix it?
> best regards,
> Chris.
Hi Michael,

Yes. My web.config file is configured correctly.

It's one of these horrible situations my app works on a different machine
that appears to be configured identicaly. The differences may be a result of
the fact that I have Visual Studio installed on my development machine but
not on the server I'm deploying to.

cheers,

Chris.

"Michael" <raterus@.localhost> wrote in message
news:%23bdDhvN5DHA.2064@.TK2MSFTNGP11.phx.gbl...
> Have you put your <appSettings></appSettings> outside of the <system.web>
> <configuration>
> <appSettings>
> <add key="WhateverValue" value="1234" />
> </appSettings>
> <system.web>
> ...
> </system.web>
> </configuration>
> Also web.config is case sensitive, but I don't think that matters as far
as
> attribute values.
> HTH,
> --Michael
> "Chris V" <varleycNOSPAM@.gaelREMOVETHISquality.co.uk> wrote in message
> news:40165cab@.news.star.co.uk...
> > I'm having a problem deploying my ASP.NET application to a WIN2k server.
> > (IIS5 .NET 1.1)
> > When I try to access ConfigurationSettings.AppSettings("WhateverValue")
I
> > get an "Object reference not set to an instance of an object." message
> > I thought this may have been to do with Virtual Directory settings but
> I've
> > got the folder set as an application in IIS and asp.net is installed and
> > working. My web.config file is Not Marked read-only and I can't see any
> > other problems with the setup. pages that do not attempt to read
settings
> > from the web.config work correctly.
> > Has anyone else come across this problem, and if so, how did you fix it?
> > best regards,
> > Chris.
Not sure. Do you have a single web.config file on the whole site ? Perhaps
another one could be read instead ? If you change some other setting in this
file is it taken into account ?

--

"Chris V" <varleycNOSPAM@.gaelREMOVETHISquality.co.uk> a crit dans le
message de news:401669e1@.news.star.co.uk...
> Hi Michael,
> Yes. My web.config file is configured correctly.
> It's one of these horrible situations my app works on a different machine
> that appears to be configured identicaly. The differences may be a result
of
> the fact that I have Visual Studio installed on my development machine but
> not on the server I'm deploying to.
> cheers,
> Chris.
>
> "Michael" <raterus@.localhost> wrote in message
> news:%23bdDhvN5DHA.2064@.TK2MSFTNGP11.phx.gbl...
> > Have you put your <appSettings></appSettings> outside of the
<system.web>
> > <configuration>
> > <appSettings>
> > <add key="WhateverValue" value="1234" />
> > </appSettings>
> > <system.web>
> > ...
> > </system.web>
> > </configuration>
> > Also web.config is case sensitive, but I don't think that matters as far
> as
> > attribute values.
> > HTH,
> > --Michael
> > "Chris V" <varleycNOSPAM@.gaelREMOVETHISquality.co.uk> wrote in message
> > news:40165cab@.news.star.co.uk...
> > > I'm having a problem deploying my ASP.NET application to a WIN2k
server.
> > > (IIS5 .NET 1.1)
> > > > When I try to access
ConfigurationSettings.AppSettings("WhateverValue")
> I
> > > get an "Object reference not set to an instance of an object." message
> > > > I thought this may have been to do with Virtual Directory settings but
> > I've
> > > got the folder set as an application in IIS and asp.net is installed
and
> > > working. My web.config file is Not Marked read-only and I can't see
any
> > > other problems with the setup. pages that do not attempt to read
> settings
> > > from the web.config work correctly.
> > > > Has anyone else come across this problem, and if so, how did you fix
it?
> > > > best regards,
> > > > Chris.
> > >
> When I try to access ConfigurationSettings.AppSettings("WhateverValue") I
> get an "Object reference not set to an instance of an object." message
> It's one of these horrible situations my app works on a different machine
> that appears to be configured identicaly. The differences may be a result
of
> the fact that I have Visual Studio installed on my development machine but
> not on the server I'm deploying to.

Compare your machine.config files for the different machines. They should
both have these sections:

<configuration>
<configSections>
<section name="appSettings"
type="System.Configuration.NameValueFileSectionHandler, System,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</configSections>
</configuration
If one of them doesn't or they differ, try fixing it for the machine that is
giving you trouble.

Martin.

0 comments:

Post a Comment