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 / ASP.NET / General / May 2008

Tip: Looking for answers? Try searching our database.

Getting Access Violation every time I modified web.config

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Raymon Du - 30 May 2008 03:23 GMT
Hi,

I am getting the following exception every time I modified web.config, the
only way to fix it is to recycle application pool or restart IIS, but I
don't want to do that all the times. TIA

.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.AccessViolationException: Attempted to read or
write protected memory. This is often an indication that other memory is
corrupt.

Source Error:

[No relevant source lines]

Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\aspdotnetstorefront70\8208fb2b\b0ed0a81\App_global.asax.kh-ttsyu.0.cs
Line: 0

Stack Trace:

[AccessViolationException: Attempted to read or write protected memory. This
is often an indication that other memory is corrupt.]
  ASP.global_asax..ctor() in
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\aspdotnetstorefront70\8208fb2b\b0ed0a81\App_global.asax.kh-ttsyu.0.cs:0

[TargetInvocationException: Exception has been thrown by the target of an
invocation.]
  System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean
publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle&
ctor, Boolean& bNeedSecurityCheck) +0
  System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean
fillCache) +103
  System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean
skipVisibilityChecks, Boolean fillCache) +268
  System.Activator.CreateInstance(Type type, Boolean nonPublic) +66
  System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder
binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
+1036
  System.Activator.CreateInstance(Type type, BindingFlags bindingAttr,
Binder binder, Object[] args, CultureInfo culture, Object[]
activationAttributes) +114
  System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr
appContext, HttpContext context) +197
  System.Web.HttpApplicationFactory.GetSpecialApplicationInstance() +27
  System.Web.HttpApplicationFactory.FireApplicationOnStart(HttpContext
context) +3460678
  System.Web.HttpApplicationFactory.EnsureAppStartCalled(HttpContext
context) +125
  System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext
context) +99
  System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +350

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.1433;
ASP.NET Version:2.0.50727.1433
Mark Rae [MVP] - 30 May 2008 03:34 GMT
> I am getting the following exception every time I modified web.config, the
> only way to fix it is to recycle application pool or restart IIS, but I
> don't want to do that all the times. TIA

Modifying web.config will cause an ASP.NET application to recycle... There
are some really convoluted (and totally pointless) exceptions to this, which
are best avoided...

If you don't want your ASP.NET application to recycle, don't modify
web.config... Store dynamic variables somewhere else...

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Raymon Du - 30 May 2008 03:44 GMT
I don't understand your response at all.  Don't modify web.config at all?
Where do you suggest me to connection strings?  Har coded in some .cs files?
It's a common practice to store connection strings into web.config then
change them for switching to defferent environments.  But ASP.Net runtime
throws exceptions if connection strings are changed in my case.

>> I am getting the following exception every time I modified web.config,
>> the only way to fix it is to recycle application pool or restart IIS, but
[quoted text clipped - 6 lines]
> If you don't want your ASP.NET application to recycle, don't modify
> web.config... Store dynamic variables somewhere else...
Mark Rae [MVP] - 30 May 2008 04:46 GMT
[top-posting corrected]

>>> I am getting the following exception every time I modified web.config,
>>> the only way to fix it is to recycle application pool or restart IIS,
[quoted text clipped - 8 lines]
>
> I don't understand your response at all.

OK.

> Don't modify web.config at all?

Yes, that's right. DON'T MODIFY WEB.CONFIG AT ALL!

> Where do you suggest me to [store] connection strings?

In web.config - as many as you need.

> Hard coded in some .cs files?

Absolutely not.

> It's a common practice to store connection strings in web.config then
> change them for switching to different environments.

It most certainly isn't!!! Web.config is not designed for this sort of
behaviour, as you've discovered... Web.config is designed for storing
application-specific data and metadata WHICH NEVER CHANGES while the
application is running.

> But ASP.Net runtime throws exceptions if connection strings are changed in
> my case.

Yes, that's correct. Because web.config is not designed to be used in this
way...

Why do you need to modify your connection string(s) while your web
application is running?

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Juan T. Llibre - 30 May 2008 07:24 GMT
re:
!> I don't understand your response at all.  Don't modify web.config at all?

He didn't say that at all.
He said "If you don't want your ASP.NET application to recycle, don't modify web.config".

If you modify web.config, your ASP.NET application *will* recycle.

re:
!> Where do you suggest me to connection strings?
!> Har coded in some .cs files?

No, but you could have a helper config file named connections.config, for example.

<connectionStrings configSource="connections.config"/>

To enable the configuration to be recognized on any change to "connections.config",
edit machine.config, in the <configSections> section, and edit <section name="connectionStrings" ... >,
adding : restartOnExternalChanges="true"

That'd make it :

<section name="connectionStrings" type="System.Configuration.AppSettingsSection, System.Configuration,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" restartOnExternalChanges="true"
requirePermission="false" />

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================

>I don't understand your response at all.  Don't modify web.config at all? Where do you suggest me to connection
>strings?  Har coded in some .cs files? It's a common practice to store connection strings into web.config then change
[quoted text clipped - 9 lines]
>> If you don't want your ASP.NET application to recycle, don't modify web.config... Store dynamic variables somewhere
>> else...

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.