console-application

How to add AutoMapper to DI in .Net core 2.0 Console Application

穿精又带淫゛_ 提交于 2019-11-28 02:12:46
I try to use AutoMapper in my .Net Core 2.0 Console Application. My class looks like this: public class AutoGetCurrency { private readonly IMapper mapper; public AutoGetCurrency(IMapper mapper) { this.mapper = mapper; } .... } I tried to add services into Main method: static void Main(string[] args) { var services = new ServiceCollection(); ServiceProvider = services.BuildServiceProvider(); services.AddTransient<IMapper>(); .... } But I have the next error 'One or more errors occurred. (Object reference not set to an instance of an object.)' Please tell me how to add AutoMapper to use DI. You

Schedule a C# console application

送分小仙女□ 提交于 2019-11-28 01:59:59
问题 I've given a task to create an email C# console application which targeted to run as batch. I'm very new to C# area and hence I have no idea about my direction. This C# console application will be deployed on a server and expect to run in certain time based on server time. After some research, most of the suggestions are about using task scheduler or window services, but I'm wondering if this C# console application is somehow possible to run own its own? Maybe after execute it, it then

Required widgets for displaying a 1D console application

拥有回忆 提交于 2019-11-28 01:45:28
I am trying to make a 1D console application using Urwid for displaying a user editable application form as shown below. _________________________ | Application Form | | ---------------- | | ' ' | | ' ' | | ---------------- | | | | ---------------- | | ' --------- ' | | ' ' ' ' | | ' --------- ' | | ' ' | | ---------------- | | | |_________________________| Consider the outer rectangle as one window or widget that contains the header title "Application Form" and other smaller windows inside it. The smaller windows or widgets can contain other windows. In each of the smaller windows, some text

console application gui for python

删除回忆录丶 提交于 2019-11-28 01:42:32
问题 We have console application option in C#, but how do I can make a console GUI in python? I should note I want to compile and use my program in windows. Also I want to select Items in Python GUI by Enter button. 回答1: If you're using Windows you will ultimately need to integrate with the win32 console API to create a console GUI (aka. a Text UI or TUI). Your options are basically: Write your TUI using curses or the packages that sit on top of it, like urwid or npyscreen. To do this you either

How can you determine how a console application was launched?

你。 提交于 2019-11-28 01:36:47
问题 How can I tell whether the user launched my console application by double-clicking the EXE (or a shortcut), or whether they already had a command line window open and executed my console app within that session? 回答1: Stick this static field in your " Program " class to ensure it runs before any output: static bool StartedFromGui = !Console.IsOutputRedirected && !Console.IsInputRedirected && !Console.IsErrorRedirected && Environment.UserInteractive && Environment.CurrentDirectory == System.IO

Invoke delegate on main thread in console application

拥有回忆 提交于 2019-11-28 01:34:15
问题 In a Windows Application, when multiple threads are used, I know that it’s necessary to invoke the main thread to update GUI components. How is this done in a Console Application? For example, I have two threads, a main and a secondary thread. The secondary thread is always listening for a global hotkey; when it is pressed the secondary thread executes an event that reaches out to the win32 api method AnimateWindow. I am receiving an error because only the main thread is allowed to execute

Unicode input in a console application in Java

为君一笑 提交于 2019-11-28 01:18:56
I have been trying to retrieve "unicode user input" in my Java application for a small utility snippet. The problem is, it seems to be working on Ubuntu "out of the box" which has I guess OS wide encoding at UTF-8 but doesn't work on Windows when run from "cmd". The code in consideration is as follows: public class SerTest { public static void main(String[] args) throws Exception { testUnicode(); } public static void testUnicode() throws Exception { System.out.println("Default charset: " + Charset.defaultCharset().name()); BufferedReader in = new BufferedReader(new InputStreamReader(System.in,

Keeping console window open when debugging

半城伤御伤魂 提交于 2019-11-28 01:10:36
When I start a program without debugging (Ctrl+F5), I have to press a key to close the console window when the program is finished. When I start the program with debugging (F5), the console window closes immediately. Is there an option in Visual Studio that will keep the window open when debugging? (I know of a thousand ways to do it "manually" in code, but I don't want to touch the code.) Add a break point to the ending bracket of the main() method. That way if the program finishes (unless it crashes in the process - which will trigger a break anyway) it will break no matter which return

WCF Self Host Service - Endpoints in C#

巧了我就是萌 提交于 2019-11-28 00:29:58
问题 My first few attempts at creating a self hosted service. Trying to make something up which will accept a query string and return some text but have have a few issues: All the documentation talks about endpoints being created automatically for each base address if they are not found in a config file. This doesn't seem to be the case for me, I get the "Service has zero application endpoints..." exception. Manually specifying a base endpoint as below seems to resolve this: using System; using

Console messages appearing in incorrect order when reporting progress with IProgress.Report()

本小妞迷上赌 提交于 2019-11-28 00:20:37
问题 I have noticed a following behaviour. Console output messages appear in an incorrect folder when they are populated by IProgress. var recounter = new IdRecounter(filePath, new Progress<string>(Console.WriteLine)); recounter.RecalculateIds(); I am trying to improve my encapsulation, reusability and design skills. So, I have a class called IdRecounter. I want to use it in a console app for now, but later on perhaps in a WPF app or whatever. Therefore, I want the class to be completely unaware