I
I
IvanSerachev2021-06-10 21:48:12
.NET
IvanSerachev, 2021-06-10 21:48:12

Why is there no app.config config file in visual studio project?

Good day!

I am learning c# using VS 2019 Community. Now I'm trying to master connecting to localDB and MS SQL, querying data, writing data. Recently I watched a video tutorial on you tube, where a friend (using VS 2017 Community) talked in great detail about connecting using Entity, but that's bad luck, when creating it, he used a configuration file - app.config, which is not in my project ... He has it assembled automatically. I can add it via Solution Explorer, but it will be completely empty even if I set Entity after adding it.

What am I doing wrong...?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vasily Bannikov, 2021-06-10
@IvanSerachev

The modern framework (.net core) no longer uses app.config, but should use configuration.json
instead

A
Alexey Bereznikov, 2021-06-11
@gdt

Just in case you need a quick solution - create a file, add to it:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
</configuration>

Next, in your project (I hope you are using the SDK style project), add AppConfig to the group property so that it looks something like this (the rest of the properties do not need to be added if you do not have them):
<PropertyGroup>
  <OutputType>WinExe</OutputType>
  <TargetFramework>net4.5</TargetFramework>
  <UseWPF>true</UseWPF>
  <AppConfig>App.config</AppConfig>
  <ApplicationManifest>App.manifest</ApplicationManifest>
  <Nullable>enable</Nullable>
</PropertyGroup>

The file itself does not need to be added to the project separately, any None Include with CopyIfNewer do not solve the problem, because they do not change the file name.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question