Not able to run the .exe file created from c#

前端 未结 2 1458
Happy的楠姐
Happy的楠姐 2021-01-28 14:36

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 i

相关标签:
2条回答
  • 2021-01-28 14:38

    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.

    0 讨论(0)
  • 2021-01-28 14:39

    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

    0 讨论(0)
提交回复
热议问题