Connect PostgreSQL with Visual Studio 2015

hello every body ,
well i wanted to connect a postgresql to visual studio 2015 using this script bellow , so i face this msg "
An unhandled exception of type 'System.ArgumentException' occurred in System.Data.dll" every time i run my script , anyhelp pls

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Npgsql;
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            NpgsqlConnection cnx = new NpgsqlConnection("Server=127.0.0.1;Port=5432;Database=GSS;User Id=postgres;Password=madman12;");
            try
            {
                cnx.Open();
                MessageBox.Show("broooo!");
                cnx.Close();
            }
            catch (Exception )
            {
                MessageBox.Show("la");
            }
        }
    }
}

2 answers

What line is causing the error?
The catch statement looks strange.
Try remove the try catch block.

Is the DB on the same computer as your C# app?
Try
{
cnx.Open()
}
catch Exception e
{
Console.WriteLine (e.Message);
}

Can you use ODBC Data Source Admin to setup a User DSN to your DB and test the connection?