Often it is very useful to have a console besides the winform/wpf application. And its really easy to :)Create an available class:
using System;using System.Runtime.InteropServices;
public static class ConsoleEx{
/// <summary>/// Shows the Console/// </summary>[DllImport("kernel32.dll")]public static extern Boolean AllocConsole(); /// <summary>/// Hides the Console/// </summary>[DllImport("kernel32.dll")]public static extern Boolean FreeConsole();
/// <summary>/// Hides the Console/// </summary>[DllImport("kernel32.dll")]public static extern Boolean FreeConsole();
}
I then use it like this in my Code (WPF App):public partial class App : Application {
public App(){
#if DEBUG ConsoleEx.AllocConsole(); #endif }
#if DEBUG ConsoleEx.AllocConsole(); #endif
You could use this with a Linq DataContext:
MyDataContext.Log = Console.Out;
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.