0

I have created a Windows form application using C# in visual studio 2010 connecting the database in SQL server . After all my development is done i copy the exe file generated in my machine and pasted in another machine and try to execute it but it is not working .

i can see the process started in task manager but it was closed after 5 seconds . I even tried creating the setup for this application and installed in that machine still i am facing the same issue .

But in my machine it is working perfectly in the both the ways . can any one help me in finding where i went wrong .

Thanks in advance

leppie
  • 115,091
  • 17
  • 196
  • 297
Ramesh
  • 123
  • 2
  • 5
  • 15
  • 2
    Have a look in the event viewer, what error does it show? The other machine is probably missing some .dlls that your project relies on. – DGibbs Mar 05 '13 at 12:30
  • 1
    Could you tell us more about Configuration for both systems? – Joan Caron Mar 05 '13 at 12:31
  • 2
    Do you have the .net-framework installed on the other machines? in the correct version? – Tomtom Mar 05 '13 at 12:34
  • Yes, Both DGibbs and Joan are correct. Firstly be sure you have all necessary library files to execute the program with system compatibility. – tnchalise Mar 05 '13 at 12:34
  • Can you put the exact exception that you have? It could be a big number of things (Framework, x86vs x64, permissions, etc.) – Oscar Foley Mar 05 '13 at 12:48
  • i think sql connection is the problem below is the error log i got from eventviewer `Application: WellDB.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.Data.SqlClient.SqlException Stack: at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(System.Data.Common.DbConnection, System.Data.ProviderBase.DbConnectionFactory) at System.Data.SqlClient.SqlConnection.Open() at WellDB.frmSearchbyperameter..ctor() at WellDB.Program.Main()` – Ramesh Mar 06 '13 at 07:09

2 Answers2

1

As you don't provide the error, the answers and comments you are getting are educated guesses.

You should check the event viewer for errors...

This will let you learn what is going on. If you can't fix it, add this info to your question.

As you are not posting exception message, probably you re not properly catching exceptions. Just to be sure surround your main function in a Try/Catch.

In Catch, write some code to dump message exception into a file, or even better use Log4Net. For simplicity just add some code to write to a file now. Something like:

    static void Main()
    {
        try
        {
            //Your code
        }
        catch (Exception ex)
        {
            //Write ex.Message to a file
            using (StreamWriter outfile = new StreamWriter(@".\error.txt"))
            {
                 outfile.Write(ex.Message.ToString());
            }
        }
    }

PS: If it is a console application you can survive with Console.Write

Oscar Foley
  • 6,817
  • 8
  • 57
  • 90
0

Perhaps you have some referenced assemblies that you did not copy along with the application itself.

OR, the connection string is not valid when run from that other machine (if you worked with a local SQL db, or on a network or whatever and it's not accesible on that other machine)

OR, you don't have rights to run it on that other machine.

dutzu
  • 3,883
  • 13
  • 19
  • I suspect problem with sql connection i am using windows authentication in the main server is it possible for other systems to connect to this – Ramesh Mar 06 '13 at 07:11
  • If the other systems have access to the server and they have access (as in security rights) then it should work. – dutzu Mar 06 '13 at 07:28
  • in other systems no SQL server , how to check whether they will have access or not – Ramesh Mar 06 '13 at 10:37