C
C
CityzenUNDEAD2021-08-08 20:29:11
C++ / C#
CityzenUNDEAD, 2021-08-08 20:29:11

Why is there no connection?

DB on sqlExpress, connection in vs.

configuration file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=Proxy;Integrated Security=True"
        providerName="System.Data.SqlClient"/>
  </connectionStrings>
</configuration>


C#
string connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
            Console.WriteLine(connectionString);


Why the exception
ConfigurationManager.ConnectionStrings["ConnectionName"].ConnectionString возвращает null?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
meo_ra, 2021-08-08
@meo_ra

Check the appsettings.json file. It is necessary to set the property "Always copy", or "Copy a later version"
RMB to file -> Properties

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question