3

We have a DLL that extends a 3rd party application. I would like to have this DLL open up a console window when it launches purely for debugging purposes. I know of the trick to do this with a windows application (change the output type to console application). Is there any way to do this with a class library?

P.Brian.Mackey
  • 43,228
  • 68
  • 238
  • 348
  • Possible duplicate of http://stackoverflow.com/questions/3571627/show-hide-the-console-window-of-a-c-sharp-console-application ? – paddy Oct 28 '12 at 22:13
  • @paddy - That question explains how to show and hide an existing console application using Win32. That's not what I am trying to accomplish. – P.Brian.Mackey Oct 29 '12 at 00:22
  • I know in C you can use the ConsoleWindow API to create and interface with a console window in ordinary Win32 apps. It looked to me like that post did the same thing. Your application shouldn't need to be a console application. A list of console functions is here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682073(v=vs.85).aspx – paddy Oct 29 '12 at 01:37

1 Answers1

5

I'd recommend using System.Diagnostics namespace and using the Debug.*/Trace.* methods. Retrieving it is then a matter of using your IDE or (if running in another application) something like DebugView.

Brad Christie
  • 100,477
  • 16
  • 156
  • 200
  • Visual Studio is not installed on all the machines, especially production boxes. That's why attaching is a little bit of a pain. We'd need to setup remote debugging which is also not possible as us lowly devs have no admin rights. – P.Brian.Mackey Oct 28 '12 at 22:20
  • @P.Brian.Mackey: You can still use the `Trace` libraries then use the `*.config` to setup log files that you can review. – Brad Christie Oct 29 '12 at 00:18
  • Thats what we have now. It's a little annoying to go into SQL and filter log data as compared to running a console app and seeing live output. – P.Brian.Mackey Oct 29 '12 at 00:20