console-application

Error handling using process c#

帅比萌擦擦* 提交于 2019-12-05 04:10:06
问题 I have created a console application using C#, and I called it from another Windows Forms application using Process . Below is my code for Console Application static void Main(string[] args) { try { // ...my code } catch (Exception) { throw; } } Below is code for call the exe of Console application from the window application using process public void CallExe() { try { Process proc = new Process(); proc.StartInfo.FileName = @"D:\Debug\console1.exe"; proc.StartInfo.Arguments = "My args"; proc

How do I get file paths of items dropped onto a console application window?

对着背影说爱祢 提交于 2019-12-05 03:35:19
I'd like to be able to let users drag and drop files onto my console app's window so they are not forced to drag'n'drop files onto the app's icon (or link, or even worse write a command line in console). How do I get the list of paths of files I drop onto my app's window? You can just listen for the keyboard. When dragging a file onto a console window the window gets keyboard events as if the file name was entered directly. That's how you can drop a file on a cmd or PowerShell window and get the full file name as if entered directly and it works the same for your own applications too. A

URL Encoding in c# and Asp.net web api

北慕城南 提交于 2019-12-05 02:56:50
问题 I have an ASP.NET web api that receives web requests and returns Json data. browsing to this URL: http://1.2.3.4/api1/api/values/mypartname will return the following json string: { \"PartName\": \"mypartname\", \"PartDes\": \"53.6X53.6APA/ALIM1NOTPAK\", \"PartLocation\": \"A36\" } but when sending a part name that contains spaces or quotes like this: http://1.2.3.4/api1/api/values/my part na"me i get a 404 - File or directory not found. error. I'm consuming the json with a .NET 4 Console

How to escape path containing spaces

倾然丶 夕夏残阳落幕 提交于 2019-12-05 01:29:18
To pass a path with spaces to .NET console application you should escape it. Probably not escape but surround with double quotes: myapp.exe --path C:\Program Files\MyApp` becomes new string[] { "--path", "C:\Program", "Files\MyApp" } but myapp.exe --path "C:\Program Files\MyApp" becomes new string[] { "--path", "C:\Program Files\MyApp" } and it works fine and you can parse that easily. I want to extend the set of parameters given with an addition one and start a new process with the resulting set of parameters: new ProcessStartInfo( Assembly.GetEntryAssembly().Location, String.Join(" ",

How to allow migration for a console application?

限于喜欢 提交于 2019-12-04 23:25:33
问题 When using asp.net core and ef core, I have no problem when invoking add-migration init . But when I apply the same approach on a console application below, I got an error saying: Unable to create an object of type 'StudentContext'. Add an implementation of 'IDesignTimeDbContextFactory' to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time. What is the easiest way to fix this issue? The .net core console application project is

How do I start a second console application in Visual Studio when one is already running

我只是一个虾纸丫 提交于 2019-12-04 22:57:10
I am working through some examples in a WCF book. There is a Host project and Client project within a single solution. Both are console applications. The Host is the startup app, but the Client app doesn't seem to open the Console like the book says. Book says while the Host is running, run the Client. The Run button is disabled tho as it is already running. The book example definitely has them in the same solution and a single instance of Visual Studio. Anyways, what am I missing here? I have done this with two instances of VS, but I truly have never does this in a single instance. Any help

Why does my console application have command history?

可紊 提交于 2019-12-04 22:37:38
I have written a console application, which is essentially a Console.ReadLine()-Loop. When the application is waiting for input, pressing the up arrow key iterates through all previous lines of input. My application does not contain any code for this feature. What part of Windows provides this? How can I disable it? I can only image that it's either a feature of the console subsystem or implemented in Console.ReadLine(). Here is some sample code that exhibits the described behavior: namespace ConsoleApplication { class Program { static void Main(string[] args) { string input; do { input =

using qt : How To Build a Gui OnTop Of a Console Application?

白昼怎懂夜的黑 提交于 2019-12-04 22:15:22
问题 i have a console application that generated from bison (a parser) and i want to build a simple gui for it so i can send input from this gui to the console and get output from the console into the gui . i tried to do that using java process class but it doesnt work for me , please help me to do that using qt . 回答1: It depends on the complexity of the data you want to feed in/out of your console application. Low complexity Use some command switches that you pass from your Qt GUI to your console

ASP.NET Authorization from Console Application & Timeout

痴心易碎 提交于 2019-12-04 20:43:55
For what its worth, I managed to get a console application to authenticate itself with an existing ASP.NET web application. It just mimics the login page by making a post request to the login page containing the viewstate information (just as if a browser had made the request). It then catches the cookie sent back in response in a CookieContainer. The application then goes on to make multiple requests to the same page (which requires authorization). The page does some work and writes out a file on the server. The problem I'm encountering is that after the phony login, the first two requests go

Create new console from console app? C++

孤街醉人 提交于 2019-12-04 20:24:24
I am stuck on create new console window for my console application, for logger. That code works fine for GUI apps, but not work for console, and they require: CreateProcess function with the DETACHED_PROCESS flag. Logger Log; DWORD PiD; void __stdcall LoggerCore(PVOID pVoid) { AllocConsole(); while(true) { SetConsoleTitleA(Log.LoggerTittle()); Sleep(5000); } _endthread(); } char* Logger::LoggerTittle() { static char Tittle[55]; sprintf(Tittle, "Debug Logger"); return Tittle; } void Logger::LoggerInit() { CreateThread( 0 , 0 , (LPTHREAD_START_ROUTINE) LoggerCore , 0 , 0 , &PiD ); } And that