Click here to Skip to main content
15,391,980 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: C# and COM Events Pin
Richard Deeming10-Nov-21 22:44
mveRichard Deeming10-Nov-21 22:44 
QuestionDeploying a .NET App with Nuget Dependencies Pin
TNCaver29-Oct-21 5:56
MemberTNCaver29-Oct-21 5:56 
AnswerRe: Deploying a .NET App with Nuget Dependencies Pin
Gerry Schmitz29-Oct-21 7:06
mveGerry Schmitz29-Oct-21 7:06 
AnswerRe: Deploying a .NET App with Nuget Dependencies Pin
Richard Deeming31-Oct-21 23:10
mveRichard Deeming31-Oct-21 23:10 
GeneralRe: Deploying a .NET App with Nuget Dependencies Pin
TNCaver1-Nov-21 6:25
MemberTNCaver1-Nov-21 6:25 
GeneralRe: Deploying a .NET App with Nuget Dependencies Pin
Richard Deeming1-Nov-21 22:49
mveRichard Deeming1-Nov-21 22:49 
GeneralRe: Deploying a .NET App with Nuget Dependencies Pin
TNCaver2-Nov-21 6:51
MemberTNCaver2-Nov-21 6:51 
QuestionConfiguration.Save Writes Invalid Configuration File Pin
Member 1266077621-Oct-21 16:45
MemberMember 1266077621-Oct-21 16:45 
I am using VS 2019, .Net 4.5.2 on Windows 7.

I have an application which manages a configuration file for another application. The abridged version looks like:

XML
<configuration>
  <configSections>
    <sectionGroup name="ServiceConfiguration" type="My.ServiceConfiguration" >

      <section name="CustomSection" type="My.CustomSection" />

      <sectionGroup name="ServiceStepGroups" type="My.StepGroups" >

        <sectionGroup name="MyGroup1" type="My.StepGroup" />

      </sectionGroup>
    </sectionGroup>
  </configSections>

  <ServiceConfiguration>
    <CustomSection />
    <ServiceStepGroups>
      <MyGroup1 />
    </ServiceStepGroups>
  </ServiceConfiguration>
</configuration>


When I run the program to modify the configuration file to add a new group with code such as:

C#
namespace My
{
    public class StepGroups : ConfigurationSectionGroup
    {
        public My.StepGroup AddNewGroup()
        {
            My.StepGroup newGroup = new My.StepGroup();
            SectionGroups.Add("MyGroup2", newGroup);
        }
    }
}


and then save the configuration file I get

XML
<configuration>
  <configSections>
    <sectionGroup name="ServiceConfiguration" type="My.ServiceConfiguration" >

      <section name="CustomSection" type="My.CustomSection" />

      <sectionGroup name="ServiceStepGroups" type="My.StepGroups" >

        <sectionGroup name="MyGroup1" type="My.StepGroup" />

      </sectionGroup>
    </sectionGroup>
    <sectionGroup name="ServiceConfiguration" >  <!-- No type attribute and wrong place -->

      <sectionGroup name="ServiceStepGroups" >   <!-- No type attribute and wrong place -->

        <sectionGroup name="MyGroup2" type="My.StepGroup" />

      </sectionGroup>
    </sectionGroup>
  </configSections>

  <ServiceConfiguration>
    <ServiceStepGroups>
      <CustomSection />
      <MyGroup1 />
      <MyGroup2 />     <!-- This is in expected place -->
    </ServiceStepGroups>
  </ServiceConfiguration>
</configuration>


As can be seen, the new MyGroup2 declaration element gets wrapped in a new ServiceConfiguration/ServiceStepGroups construct but 1) AFTER the first construct, 2) WITHOUT type attributes and 3) WITHOUT a CustomSection section; however, the MyGroup2 configuration group IS in the right place in the configuration file below.

Why?

I would have expected the declaration of MyGroup2 to immediately follow the declaration of MyGroup1 without a second construct created.

Digging through the source code and [limited] documentation online has not been fruitful.

Is this a bug? Am I forgetting something?

It should be noted that when I load the new configuration file an exception is thrown (duplicate ServiceStepGroups section group) as would be expected; however, if I manually fix the configuration file as per my expectations previously stated the file loads successfully with the new MyGroup2 included.

Any help or insight is appreciated.

Thanks! Cool | :cool:
AnswerRe: Configuration.Save Writes Invalid Configuration File Pin
Dave Kreskowiak22-Oct-21 5:20
mveDave Kreskowiak22-Oct-21 5:20 
GeneralRe: Configuration.Save Writes Invalid Configuration File Pin
Member 1266077622-Oct-21 7:09
MemberMember 1266077622-Oct-21 7:09 
GeneralRe: Configuration.Save Writes Invalid Configuration File Pin
Member 154156281-Nov-21 18:04
MemberMember 154156281-Nov-21 18:04 
AnswerDebrief: Configuration.Save Writes Invalid Configuration File Pin
Member 1266077627-Oct-21 10:18
MemberMember 1266077627-Oct-21 10:18 
GeneralRe: Debrief: Configuration.Save Writes Invalid Configuration File Pin
Peter_in_278027-Oct-21 10:54
professionalPeter_in_278027-Oct-21 10:54 
GeneralRe: Debrief: Configuration.Save Writes Invalid Configuration File Pin
Member 1266077627-Oct-21 11:20
MemberMember 1266077627-Oct-21 11:20 
GeneralRe: Debrief: Configuration.Save Writes Invalid Configuration File Pin
Peter_in_278027-Oct-21 11:40
professionalPeter_in_278027-Oct-21 11:40 
GeneralRe: Debrief: Configuration.Save Writes Invalid Configuration File Pin
phil.o27-Oct-21 11:46
mvephil.o27-Oct-21 11:46 
QuestionMVC Controller State Managment Pin
Kunal Mandloi13-Sep-21 22:18
MemberKunal Mandloi13-Sep-21 22:18 
AnswerRe: MVC Controller State Managment Pin
Richard Deeming13-Sep-21 22:26
mveRichard Deeming13-Sep-21 22:26 
AnswerRe: MVC Controller State Managment Pin
Kunal Mandloi14-Sep-21 4:18
MemberKunal Mandloi14-Sep-21 4:18 
QuestionFramework v. Core for Windows App Pin
Richard Andrew x644-Sep-21 1:47
professionalRichard Andrew x644-Sep-21 1:47 
AnswerRe: Framework v. Core for Windows App Pin
Dave Kreskowiak4-Sep-21 4:46
mveDave Kreskowiak4-Sep-21 4:46 
AnswerRe: Framework v. Core for Windows App Pin
Richard Deeming5-Sep-21 22:10
mveRichard Deeming5-Sep-21 22:10 
QuestionUsing Postman to test HTTPPatch in .Net Core API, [FromBody] JsonPatchDocument<TEntity> patchEntity is null Pin
thewizardoftn27-Aug-21 9:52
Memberthewizardoftn27-Aug-21 9:52 
AnswerRe: Using Postman to test HTTPPatch in .Net Core API, [FromBody] JsonPatchDocument<TEntity> patchEntity is null Pin
Richard Deeming30-Aug-21 22:03
mveRichard Deeming30-Aug-21 22:03 
AnswerRe: Using Postman to test HTTPPatch in .Net Core API, [FromBody] JsonPatchDocument<TEntity> patchEntity is null Pin
Matt T Heffron31-Aug-21 11:45
professionalMatt T Heffron31-Aug-21 11:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.