System.Diagnostics.Switches ASP.NET 2.0

P

Paul Hatcher

Has there been a change in behaviour of switches between 1.1 and 2.0.

I have a web site that defines a switch and then an application that adds
the same switch but with a different value. Under 1.1, this worked and only
my sub-application reported values against the switch.

Under 2.0 I get a runtime error saying that the switch has already been
defined - is this expected behaviour?

Paul
 
S

Steven Cheng[MSFT]

Hi Paul,

Thank you for posting.

As for the System.Diagnostics Switch setting, it does has changed from .net
framework 1.1 to .net framework 2.0. In 1.1, even the folloing
configuration setting can work (without exception) and the runtime will
take the first one's value:

=====================
<system.diagnostics>
<switches>
<add name="XmlSerialization.Compilation" value="4"/>


<add name="XmlSerialization.Compilation" value="6"/>
</switches>
</system.diagnostics>
=====================

However, this is not allowed in .net framework 2.0. I have no idea of the
exact code logic however, based on my debugging, it is the
configurationRecord method of the
System.Configuration.BaseConfigurationRecord that throughs the error. And
seems 2.0 's config file parser will force us to only define a certain
switch instance(by name) once through the whole configuration
hierarchy(from machine level to application or sub app level). Therefore,
for your scenario, if you want to override a certain switch with new value,
you can first use <remove> element to remove the former definition and add
a new one. Just like:

=======================

<system.diagnostics>
<switches>
<add name="XmlSerialization.Compilation" value="4"/>

<remove name="XmlSerialization.Compilation"/>

<add name="XmlSerialization.Compilation" value="5"/>
</switches>
</system.diagnostics>
================================

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.



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

Steven Cheng[MSFT]

Hi Paul,

How are you doing on this issue or does the info in my last reply helps you
a little? If there is still anything we can help, please feel free to post
here.

Regards,

Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.



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

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top