Nouri Yacine
Nouri Yacine

Reputation: 63

c# Windows Form Application is crashed on client machine

my app is crushing on client PC . i installed another SQL server 2014 in my second laptop after changing the SQL connection string and setting file it's work for me normal . and in my developer machine " the first one" is working simple. but when i change the connection setting as i did for my laptop and take the App to client machine it crushing .

i am using the same SQL Server 2014 on all of computers.

and show this message :

enter image description here

i tried to reinstall new .Net Framework but not work too . what should i do her ?

Upvotes: 1

Views: 973

Answers (2)

Jonathan Willcock
Jonathan Willcock

Reputation: 5255

I entirely agree with the need for a Error handling in your code! Nevertheless, the following might help.

  1. I strongly recommend not having a fixed connection string within your application. That makes it very hard to port to client machines. Instead include the connection string in your Settings.

  2. On the client machine open Notepad and save a new empty file with a .udl extension (you will need to select All Files on the Save Dialog dropdown), eg testconn.udl. Now from Explorer double click the new .udl file. A Data Link Properties Window should open. On the provider tab, select SQL Server Native Client. On the Connection Tab, select the name of the client's SQL Server and fill in the other options as appropriate. Now click Test Connection. Hopefully, it will say Test succeeded. Now click OK, and re-open the .udl file in Notepad. It will have created an oledb string. For SQLClient, you will not need the "Provider=" part, and you can also ignore Initial File Name and ServerSPN; the rest however, will give you the values that the client needs as a connection string.

  3. Assuming you have done 1. and 2. you can now edit your app's config file to contain the correct connection string.

The only thing that can go wrong, is if Test Connection in 2. does not work. There could be so many reasons for this, that I will not try to second guess here. Please try it, and report back any problems. If Test Connection does not succeed, at least you can be sure that the problem is not your code!

Upvotes: 0

CShark
CShark

Reputation: 1563

In Program.cs, App.cs or App.xaml.cs you can register an exception handler which catches all exceptions that are unhandled, even those leading to a crash. Register a function to AppDomain.CurrentDomain.UnhandledException as soon as the program launches and in that handler you can dump the ExceptionObject in the second argument to a text file. That will at least give you further information to work with.

Other than that there is no way for us to pinpoint even a remote cause for that crash, as we have not enough information.

Upvotes: 1

Related Questions