应用程序在调试模式下运行,但同样不在其他文件夹中运行 [英] Application running in debug mode but the same is not working other folder

查看:49
本文介绍了应用程序在调试模式下运行,但同样不在其他文件夹中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用VS 2008在C#中编写了一个应用程序。应用程序将在使用Visual Studio的调试模式下正常运行,我将整个调试文件夹复制到.EXE无效的其他路径,没有任何反应。我没有收到来自Windows的任何错误消息,并且VS中没有错误或警告。我试图建立,重建和清理解决方案(按照每种可能的顺序),没有运气。此外,我试图附加过程我没有得到任何错误行执行但没有结果。



找到我使用的下面的代码。

I wrote an application in C# using VS 2008. The application will run fine in debug mode using Visual Studio, i copied the entire debug folder to some other path the .EXE is not working, nothing happens. I do not get any error messages from windows and there are no errors or warnings in VS. I have tried to build, rebuild and clean the solution (in every possible order) with no luck. Also i tried to attach the process i did't get any error the line executed but no result.

Find the below code which i used.

try
{
string FileName = "SqlCmd.exe";
                string element = System.Environment.MachineName + @"\" + "SQLExpress";               

                if (System.IO.File.Exists(Application.StartupPath + @"\EtasFullDBScript.sql"))
                {

                    string Arguments = @" -S " + element + " -i " + System.Windows.Forms.Application.StartupPath + (@"\EtasFullDBScript.sql");                

ProcessStartInfo info = new ProcessStartInfo(FileName, Arguments);
info.UseShellExecute = false;
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
info.RedirectStandardOutput = true;
Process p = new Process();
p.StartInfo = info;
p.Start();
p.WaitForExit(1000 * 60 * 1);
MessageBox.Show("Database created successfully...", "DB Creation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Script file does not Exists!!!", "DB Createion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }





任何想法?



Any Idea?

推荐答案

有点困难从代码中分辨出来 - 有你



a)考虑将一些像Log4Net这样的东西添加到你的编程和记录/追踪程序到达的地方



b)确保你从哪里复制调试文件夹,程序可以找到像'sqlcmd.exe',EtasFullDBScript.sql这样的工件 - 你可能需要完全指定sqlcmd.exe的路径例如



会有一些你错过的东西
bit difficult to tell from that code - have you

a) thought about adding something like Log4Net to your prog and logging/tracing where the program gets to

b) made sure from where you've copied the debug folder that the program can find artifacts like 'sqlcmd.exe', EtasFullDBScript.sql - you may need to fully specify the path to sqlcmd.exe for example

there will be something small you've missed


这篇关于应用程序在调试模式下运行,但同样不在其他文件夹中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆