Вопрос

I am using Visual Studio 2005 C#. Designing a mobile App for handheld scanners. At the moment I'm declaring a connection string on every form I have. I do not want to do this. I know you can do it app.config file.

I am struggling to understand how the app.config file works. I have read forums and stackoverflow posts, but I just can't find it. Can someone please help me with this?

Example: app.config file in C# for SQL Server 2005 in VS 2008

But where is the app.config file?

Using: Visual Studio 2005 .net 2.0

Screenshots:

enter image description here

enter image description here

app.config file :

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <connectionStrings>
    <add name="MyString" 
         connectionString="User Id=christob;Password=CHRISTOB;Host=poseidon;Pooling=true;Min Pool Size=0;Max     Pool Size=100;Connection Lifetime=0;Port=1523;Sid=GLODCQA"
         providerName="CoreLab.Oracle" />
  </connectionStrings>
</configuration>



using System.Configuration;

private void btnExit_Click_1(object sender, EventArgs e)
    {
        string sTemp = System.Configuration.ConfigurationManager.ConnectionStrings["MyString"].ConnectionString;
etc........
    }

Error:

Error 1 Deployment and/or registration failed with error: 0x8973190e. Error writing file '%csidl_program_files%\hhrcv_app\system.dll'. Error 0x80070070: There is not enough space on the disk. Device Connectivity Component

Why do I get this error? I only get it when I use systems.configuration; But i have to?

Это было полезно?

Решение

If you don't have a template for it, you can create the file manually. The default App.config file that Visual Studio generates contains the following text:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
</configuration>

Create a text file called App.config in your solution directory with the above text in it, then add it to your project as an existing item.

Другие советы

It's a file you can add to your project.

Add => New Item => Visual C# Items => General => Application Configuration File

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top