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

前端 未结 2 1457
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: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

提交回复
热议问题