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

*爱你&永不变心* 提交于 2019-12-02 09:34:21

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.

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!