a blog about Development and Tech stuff by Kristian S. Ravndal RSS 2.0
# Tuesday, July 22, 2008

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();

}


I then use it like this in my Code (WPF App):
public partial class App : Application
{

public App(){

#if DEBUG
ConsoleEx.AllocConsole();
#endif

}

}

You could use this with a Linq DataContext:

MyDataContext.Log = Console.Out;

Tuesday, July 22, 2008 12:49:06 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0] - Trackback
Tips&Tricks
Comments are closed.
Navigation
Archive
<September 2010>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789
Other blogs
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
Kristian Sølve Ravndal
Sign In
Statistics
Total Posts: 5
This Year: 0
This Month: 0
This Week: 0
Comments: 3
Themes
All Content © 2010, Kristian Sølve Ravndal
DasBlog theme 'Business' created by Christoph De Baene (delarou)