Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > have problem with my App.config EXE file ??????
 

have problem with my App.config EXE file ??????

hello

i have windows application form depened on query some data from SQL Server 2005 Express Edition Database

i save my connection string in App.Config File on my project

here is the part in app file

<appSettings>
 <add key="MyConstring"  value="Data Source=HEKO\SQLEXPRESS;Initial Catalog=Zanussi;Integrated Security=True;Pooling=False" ></add>
        </appSettings> 
so i have include my exe file in application deploy package under Application Folder and User Programs Menu

so and install on another machine on computer have SQL Server Express Edition with this server name : SHADY\SQLEXPRESS

as you know my server : HEKO\SQLEXPRESS

so i opened the app exe file from the programs menu on the XP windows and open app file with Notepad and replace the Server Name as some people told me thati have to do so my question is why this process didnt effect and still have problem to reach my database source and gives me error about the instance error or sql server doesnt support Remote connection that the errori have when try to open my database query from my form

is any possible solution and i wanna know the Application file root on Installation project where its deploy this data .i just seemy project on Users Menu Programs

if any one need more explainations please send me as soon is possible because i have to help my customer and use my application thanks

H.HEMDAN ISMAILIA - EGYPT  Sunday, September 13, 2009 1:02 AM

Hi H.HEMDAN ISMAILIA �EGYPT,

I think I got the key problem. Based on my understanding, you used Setup Project to create a install package and want to modify the connection string in the app.config file after the installation.

We can add a custom action to the setup project to solve the issue, below are the details.

Create the custom action library:

1. Create a library project and add a custom Installer class to the project.

2. Add a Form to the project. The form accepts a string parameter as the install directory.

3. In the form, handle the connection string modifying logic, such as accept some input as data source, find the [program name].exe.config and modify the connection string. The thread below shows how to modify the config file:
http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/cb9b4823-1dc4-4721-9797-f65bd0de6135.

4. Override the Commit method in which the added form is shown and the connection string is modified.

Add a custom action to the Setup Project:

1. Add the custom action library to the Application Folder in File System view.

2. Add the custom action library to the Commit folder in the Custom Actions view.

3. Right click the added custom action library in the Commit folder and set its CustomActionData property to /name="[TARGETDIR]\". The thread below shows how to pass the install directory to the custom action and targetdir in detail:
http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/d8c1be8a-a431-4d0c-bdca-01dde8c94b2a.

The walkthrough below shows how to add a custom action:
http://msdn.microsoft.com/en-us/library/d9k65z2d(VS.80).aspx.

The walkthrough below shows how to pass data to a custom action :
http://msdn.microsoft.com/en-us/library/9cdb5eda(VS.71).aspx.

Let me know if this does not help.
Aland Li


Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Friday, September 18, 2009 3:35 AM

Hi H.HEMDAN ISMAILIA �EGYPT,

You said: so i have include my exe file in application deploy package under Application Folder and User Programs Menu.

Do you mean that you have created a Setup Project and add the Project Output to the Application Folder in File System view?

You also said: is any possible solution and i wanna know the Application file root on Installation project where its deploy this data .i just seemy project on Users Menu Programs

Do you mean that you want to know the install directory of the program? In Setup Project, there is a step during installing which allows the user to select a install directory. The install directory would often be like this: C:\Program Files\[Manufacturer]\[]ProductName] or C:\Program Files (x86)\[Manufacturer]\[]ProductName].

To solve the issue: the data source cannot be reached, we need to check the items below:

1. If the database can be accessed on another machine.

As default, the sql server database would not allow remote connections, we can follow the links below to enable it:

Sql server 2005:
http://support.microsoft.com/default.aspx/kb/914277

http://blogs.msdn.com/sql_protocols/archive/2006/09/30/SQL-Server-2005-Remote-Connectivity-Issue-TroubleShooting.aspx

Sql server 2008:
http://www.linglom.com/2009/03/28/enable-remote-connection-on-sql-server-2008-express/.

http://forums.asp.net/t/1338911.aspx.

Then we can open SQL Server Management Studio on another machine and try to connect to the server to see if we did enable it successfully.

2. If the connection string is correct.

Before we decide the Data Source in a connection string, we need to know the server name and the instance name. The server name is often a URL address or a IP address, such as www.hello.com or 192.168.2.3. We can know the instance name by following this thread: http://social.msdn.microsoft.com/Forums/en-US/sqlgetstarted/thread/eb58a7fe-4647-4eea-91e3-6ee369362d64.

This document is about instance name:
http://msdn.microsoft.com/en-us/library/ms143744(SQL.90).aspx.

When we know these two names, Data Source can be formatted as follows:
[server name]\[instance name].

The connection string can be as follows:
Server=myServerName\theInstanceName;Database=myDataBase;Trusted_Connection=True;

You can get more information about sql server connection strings from:
http://www.connectionstrings.com/sql-server-2005.

Let me know if this does not help.
Aland Li


Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Wednesday, September 16, 2009 4:04 AM

hey , look i developed my application on my machine okay and my computer name is Heko and i already have my VS and sql server management studio on my machine with Data source i have to use to connect on my machine Heko\SQLEXPRESS

but i went to my client and i installed my application and i installed sql server and management studio and attache my database but the sql server on this client machine didnt Heko\SQLEXPRESS as mine it should be as i see it Shady\SQLEXPRESS

here is the point i save my connection on app.conf file to only change the name from mine to the client and then i must see my win form connect successuflly to the database so i readed once that i have to include my app.config file beside the primary output i added to my setup project and then i install my application and navigate to the file and open it with notepad and changed the source to Shady\SQLEXPRESS

so i dont need to allow remote connection because i just do it locally exctly as i make on my local machine i just want the step of change the sourcename and make it work

H.HEMDAN ISMAILIA - EGYPT  Thursday, September 17, 2009 3:39 PM

Hi H.HEMDAN ISMAILIA �EGYPT,

I think I got the key problem. Based on my understanding, you used Setup Project to create a install package and want to modify the connection string in the app.config file after the installation.

We can add a custom action to the setup project to solve the issue, below are the details.

Create the custom action library:

1. Create a library project and add a custom Installer class to the project.

2. Add a Form to the project. The form accepts a string parameter as the install directory.

3. In the form, handle the connection string modifying logic, such as accept some input as data source, find the [program name].exe.config and modify the connection string. The thread below shows how to modify the config file:
http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/cb9b4823-1dc4-4721-9797-f65bd0de6135.

4. Override the Commit method in which the added form is shown and the connection string is modified.

Add a custom action to the Setup Project:

1. Add the custom action library to the Application Folder in File System view.

2. Add the custom action library to the Commit folder in the Custom Actions view.

3. Right click the added custom action library in the Commit folder and set its CustomActionData property to /name="[TARGETDIR]\". The thread below shows how to pass the install directory to the custom action and targetdir in detail:
http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/d8c1be8a-a431-4d0c-bdca-01dde8c94b2a.

The walkthrough below shows how to add a custom action:
http://msdn.microsoft.com/en-us/library/d9k65z2d(VS.80).aspx.

The walkthrough below shows how to pass data to a custom action :
http://msdn.microsoft.com/en-us/library/9cdb5eda(VS.71).aspx.

Let me know if this does not help.
Aland Li


Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Friday, September 18, 2009 3:35 AM

You can use google to search for other answers

Custom Search

More Threads

• Updating newer to older!?
• Where to start
• Non-administrator user and Misc
• How to inform the end user if .msi file is dbl clicked that they need to run the .exe
• VS.NET 2008 sp1: Deployment project shortcut points to application folder not to the actual .EXE filename in the application folder
• Including Driver with Application Setup...
• Change working directory for a custom action
• The value of the 'PublicKey' attribute in '.NET Framework 3.5' does not match that of ...
• Problem with .net framework Version
• Bootstrapper MSI double download