Error Installing Application on Another Computer: Invalid Connection String

Roberto Carlos Melgar Dorado 80 Reputation points
2024-02-25T00:40:15.0533333+00:00

Good evening dear community, I am bringing up my problem again since I have not been able to find a solution. To the point: I created a small application with a single Windows Forms form. It has its own connection string to the database and an example table. It works correctly in development, but it does not work when I run it on a virtual machine with Windows 10 and SQL Server 2019, even after changing the server name. To help me find the error, I am showing you all the code I have created: It is worth noting that I published the application with OneClick. Here is the complete code of the project, which is divided into three layers: App.config


Clase de conexixón


The class to load product data


Now I also have the connection string in the application properties.
Imagen1

Now when I publish the application, it generates the following files:
Captura2

The following files are generated inside the folder:
Captura3

Okay, when I install the application, only a single file with the application's name is created inside the Programs folder, where all the programs are located. I understand that the other configuration files should also be created, without the .deploy extension, for example, the configuration file CapaPresentacion.exe.config.deploy. However, it is not created. Now, in this CapaPresentacion.exe.config.deploy file, I change the server name to point to the new server, but I get errors, one of them being that the connection string could not be initialized. I also want to mention that when I install it on the computer where I created the application, it runs without problems. Please, where can my error be? Please help me solve it. Thank you very much. Good evening.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,396 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,754 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,274 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. gekka 6,666 Reputation points MVP
    2024-02-25T02:22:17.11+00:00

    If you edit the ClickOnce files after published, the files will be tampered file and the installer check will be error.
    Therefore, after editing *.config.deploy, the files must be re-signed.

    Re-sign application and deployment manifests

    0 comments No comments

  2. Shujaat Abdi 0 Reputation points
    2024-02-25T03:51:01.5766667+00:00

    Hi Roberto, I think the issue is in the Instance name of the Database Server..so please check instance name closely and do one thing, check the configuration of the Microsoft SQL Server database for remote access. there can be one more thing that is, right click on your App and Run As Administrator, if this trick works and app connects with the Database successfully then let me know I'll give you the solution.

    0 comments No comments

  3. Roberto Carlos Melgar Dorado 80 Reputation points
    2024-04-23T16:08:38.42+00:00

    In order to not leave the question unanswered, the truth is that I do not know to what extent my answer is true, but I want to comment that I found the directory where the configuration files of the App that I installed were installed or saved, where you can change the data of the connection string, and that is precisely this directory.

    "C:\Users\rober\AppData\Local\Apps\2.0\49VZ6KQT.2ZX\1CX0002L.QL8\capa...exe_0000000000000000_0001.0000_none_dc433a31787c5191"

    With this, I close my question and provide a possible answer.

    0 comments No comments