How do I specify the exit code of a console application in .NET?

I have a trivial console application in .NET. It's just a test part of a larger application. I'd like to specify the "exit code" of my console application. How do I do this?

How to use HttpWebRequest (.NET) asynchronously?

How can I use HttpWebRequest (.NET, C#) asynchronously?

Best way to reverse a string

I've just had to write a string reverse function in C# 2.0 (i.e. LINQ not available) and came up with this: public string Reverse(string text) { char[] cArray = text.ToCharArray(); string...

Replace Line Breaks in a String C#

How can I replace Line Breaks within a string in C#?

How do I get a human-readable file size in bytes abbreviation using .NET?

How do I get a human-readable file size in bytes abbreviation using .NET? Example: Take input 7,326,629 and display 6.98 MB

When should one use Environment.Exit to terminate a console application?

I'm maintaining a number of console applications at work and one thing I've been noticing in a number of them is that they call Environment.Exit(0). A sample program would look like this: public...

.NET Console Application Exit Event

In .NET, is there a method, such as an event, for detecting when a Console Application is exiting? I need to clean up some threads and COM objects. I am running a message loop, without a form,...

ClickOnce error: Value does not fall within the expected range

Getting this error on ALL ClickOnce application launches for a certain user. This started happening after a version upgrade (but happens to no one else). I've tried subsequently changing the...

How can I remove the border of a WPF window when using luna or classic?

When I display a WPF window with WindowStyle="None", it looks great when using areo. However, when I use luna or classic, it displays an ugly gray border about 5 pixels wide. Of course, if I set...

A definitive guide to API-breaking changes in .NET

I would like to gather as much information as possible regarding API versioning in .NET/CLR, and specifically how API changes do or do not break client applications. First, let's define some...

Does .NET have a way to check if List a contains all items in List b?

I have the following method: namespace ListHelper { public class ListHelper<T> { public static bool ContainsAllItems(List<T> a, List<T> b) { return...

Best C# API to create PDF

Can you recomend any PDF API for C#. Free is the best, but I don't mind paying for it.

Set the SecurityProtocol (Ssl3 or TLS) on the .net HttpWebRequest per request

My application (.net 3.5 sp1) uses the HttpWebRequest to communicate with different endpoints, sometimes its over HTTPS where each hosting server may have a different security protocol requirement...

How to implement re-try n times in case of exception in C#?

I am developing a WPF 4.0 application in which we get the data from a remote web service. The web service exposes around 120+ methods to its clients. If a web service call from my WPF application...

Printing Right-To-Left in c#

According to msdn: http://www.microsoft.com/middleeast/msdn/arabicsupp.aspx (Link Expired!) How GDI+ Support Arabic? GDI+ supports Arabic text manipulation including print text with RTL reading...

string values to byte array without converting

I'm trying to put the values of a string into a byte array with out changing the characters. This is because the string is in fact a byte representation of the data. The goal is to move the input...

Why is the console window closing immediately once displayed my output?

I'm studying C# by following the guides in MSDN. Now, I just tried the Example 1 (here is the link to MSDN), and I've encountered an issue: why is the console window closing immediately once...

Catch Oracle timeout exceptions

I want to handle timeout exceptions differently from other SQL exceptions, much like https://stackoverflow.com/questions/29664/how-to-catch-sqlserver-timeout-exceptions However, our application...

How to create timestamp in seconds

I have this task to populate this field: x_fp_timestamp is the timestamp created when the form is generated. It is equal to the number of seconds since January 1, 1970 in UTC (Coordinated...

Rx .Net TestScheduler- executing immediately scheduled events

When I do this: testScheduler.Schedule("Hello world",(scheduler, state) => Console.WriteLine(state)); testScheduler.AdvanceTo(testScheduler.Now); I hit this code in...

Where to find csc.exe in .NET Framework 4.5?

I try to find csc.exe to add this to PATH system variable. I have been install Microsoft .NET Framework 4.5 SDK. Why I don't see v4.5 in C:\Windows\Microsoft.NET\Framework64? Where to find...

Oracle.DataAccess.Dll loading issue on x-64 machine

I have a .net exe program which is using Oracle.DataAccess, Version=2.121.1.0 dll. My development machine and tfs build server both are 32-bit. Everything is working fine on 32 machines. But now...

Show message Box in .net console application

How to show a message box in a .net c# or vb console application ? Something like: Console.WriteLine("Hello World"); MessageBox.Show("Hello...

GDS Implementation (Sabre,Amadeus,worlspan)

We want to develop a system which will communicate to various GDS's (Sabre,Amadeus,worlspan) for the Car rentals.which will push/ pull the data from GDS, we don't have any documents as such right...

Extracting and Parsing the WWW-Authenticate header from HttpResponseMessage in .NET

I'm building an app using Azure AD to call the Microsoft Graph. In certain requests that require elevated access, the graph is issuing an HTTP 403 error with a special claims parameter inside the...

System.Net.Mail.MailAddress send to multiple emails with one parameter

I've just switched from the deprecated System.Web.Mail.MailAddress to System.Net.Mail.MailAddress, but it doesn't seem to be particularly flexible when passing in a parameter holding multiple...

How to create System.IO.StreamWriter with Encoding in Powershell?

I'm trying to create instance of StreamWriter with UTF8 encoding in PowerShell. $f = New-Object System.IO.StreamWriter "a.txt", $false, [System.Text.Encoding]::UTF8 This throws error: New-Object...

Uploading a file to WebDAV server using WebClient.UploadFile returns 401

I try to upload files from my C# application on a Windows client to a Linux webserver through WebDAV. To achieve this I am using WebClient.UploadFile(). The upload always throws an exception: The...

ASP.NET Misconfiguration: Improper Model Validation

I have below simple class but veracode reporting below flaws Insufficient Input Validation( 7 flaws) ASP.NET Misconfiguration: Improper Model Validation (CWE ID 1174)(7 flaws) Please help me to...

Update From Bootstrap 3.7 to 5.0.2 in .net mvc producing Error- System.NullReferenceException

I uninstalled the basic bootstrap template that comes with .net MVC Application and installed the bootstrap 5.0.2 from NuGetPackage Manager. Now I am Encountering this Problem At the runtime...