如何使Visual Studio解决方案从命令行运行? [英] How to make the visual studio solution run from command line?

查看:710
本文介绍了如何使Visual Studio解决方案从命令行运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Visual Studio应用程序,可以从ini文件中读取IP地址和端口号,并在该套接字上发送数据.
我必须从命令行运行该程序.现在,我打开Visual Studio并通过单击debug运行该程序.如何从命令行运行该程序.
我如何将解决方案转换为命令行?

I have an visual studio application that reads the ip address and port no from an ini file and send the data on that socket.
I have to run the program from command line.Right now i open the visual studio and run the program by clicking on debug.How to run the program from command line.
How do i convert the solution into the command line?

推荐答案

只需打开控制台"Cmd.exe"并导航至您的输出文件夹.在那里启动exe.因此,如果您的exe文件名为"Test.exe"并且位于C:\ Temp中,则只需执行
Just open the console "Cmd.exe" and navigate to your output folder. There just start the exe. So, if your exe is called "Test.exe" and lies in C:\Temp, just execute
C:\Temp\Test.exe




您需要使用 Environment GetCommandLineArgs 函数来访问参数.您需要检查应用程序的入口点.在那里,您需要获取并处理您的参数.

如果缺少参数,还需要指定适当的异常或其他消息.

像这样

Hi,

You need to use Environment GetCommandLineArgs function to access your parameters. you need to check what is the entry point of your application. there you need to get and process your parameters.

You also need to specify appropriate exception or further message if parameter are missing.

Something like,

using namespace System;
int main()
{
   Console::WriteLine();

   //  Invoke this sample with an arbitrary set of command line arguments.
   array<String^>^arguments = Environment::GetCommandLineArgs();
   Console::WriteLine( "GetCommandLineArgs: {0}", String::Join( ", ", arguments ) );
}


(来自MSDN的代码)

希望这对您有用,
谢谢
-Amit Gajjar


(Code from MSDN)

Hope this works for you,
Thanks
-Amit Gajjar


这篇关于如何使Visual Studio解决方案从命令行运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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