I have a C# library project that was building correctly in Visual Studio 2022, using .NET Standard 2.1. In it I use System.Configuration.ConfifurationSection
and related items to read the project config.
Yesterday I switched from using Log4net for logging to using Serilog for logging. Once I had that working I removed the package reference to Log4net. As soon as I did that I started getting errors regarding classes and the like in System namespaces.
For instance:
Error CS0246: The type or namespace name 'ConfigurationSection' could not be found (are you missing a using directive or an assembly reference?)
A version of my code is without proprietary material is:
using System.Configuration;
namespace MyNamespace
{
public class MyConfig : ConfigurationSection
{
// ...
}
}
Note the removal of the package reference is the only change I made since the last successful build.
Any ideas on how to get past this issue? It is clearly not the usual missing using directive.
C# Tools: 4.6.0-3.23259.8
ASP.NET and Web Tools: 17.6.326.62524
I tried explicitly qualifying the name
ConfigurationSection
with the namespaceSystem.Configuration
I tried to rebuild the solution
I have tried exiting and restarting Visual Studio
None of these made any difference, except in the first case for a slight change in wording of the error message.
I tried searching for answers on the Web, but all answers were for much earlier versions of Visual Studio, or for other IDEs. None were relevant.
Switching to the Release build from Debug build "fixed" the issue. But leaving it that way leaves us with no debug build for testing.