I have a .exe that points to two other .config files (NOT the .exe of the running .config). .config1 is the source and .config2 is the target. I want to copy a section that is present in .config1 into .config2. When I use this code:
targetConfig.Sections.Add("newSection", sourceSection);
targetConfig.Save(ConfigurationSaveMode.Modified);
I get an null ref, even though when I traverse the graph in both the source and the target, everything looks instantiated.
When I follow the MSDN docs about how to use the .Add method in context of thethe .OpenMappedExeConfig method found here, it creates a new class in code. When I do that, the insert works fine. Has anyone else run into this issue?