Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am getting errors in my app.config file when I start my project.

System.Configuration.ConfigurationErrorsException: 'Configuration system failed to initialize'

ConfigurationErrorsException: Unrecognized configuration section system.net. (C:\Repos\Test_Email\XXXXXXX\bin\Debug\net5.0-windows\SpeadIMUI.dll.config line 3)



App.Config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.net>
    <mailSettings>
      <smtp deliveryMethod="Network">
        <network host="xxxx.xxxxxx.com" port="993" userName="xxx@xxxxxx.com" password="XXXXXXXXX" defaultCredentials="false" enableSsl="true" targetName="STARTTLS/mail.xxxxxxxx.com" />
      </smtp>
    </mailSettings>
  </system.net>
 <connectionStrings>
    <add name="testing1" connectionString="Server=localhost;Port=3306;database=AAAA;user id=BBBB;password=XXXXX" /> 
 </connectionStrings>
</configuration>


What I have tried:

If I remove system.net it errors on mailSettings. I have searched and cannot find anything on this. I think it might have something to do with .net 5 but not sure.
Posted
Updated 4-Nov-21 3:57am

If you are trying to migrate an older .NET application to .NET 5 that can be difficult.
To give you an idea, see: Tools for Estimating Your .NET 5 Migration[^]
 
Share this answer
 
SmtpClient is obsolete, and shouldn't be used in .NET Core or .NET 5/6/...

We don't recommend that you use the SmtpClient class for new development because SmtpClient doesn't support many modern protocols. Use MailKit[^] or other libraries instead. For more information, see SmtpClient shouldn't be used[^] on GitHub.


Unrecognized configuration section system.net in .net core 2 · Issue #24083 · dotnet/runtime · GitHub[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900