Re: How to get stdout/stderr from unmanaged DLL?
- From: Thomas W. Brown <thomas_w_brown@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 15 Jun 2005 08:21:09 -0700
Not necessarily, I just mean in a non-interactive way. Actually what I'm
trying to do is the following. I have a WindowsService which responds to
specific IPC commands by starting a utility application. It is this utility
application for which I want to get stdout redirected to a log file.
Reassigning my own TextWriter via Console.SetOut and Console.SetError *does*
correctly route all Console.WriteLine and Console.Error.WriteLine type of
calls from my managed code despite the fact that the app is running without a
console window. But any output from PInvoked calls to these unmanaged DLLs
is lost. I ensure that a Console exists for my application (via
AllocConsole) but this doesn't have any effect.
I know I could redirect to a temp file on the process startup from my
service and then get all output after the fact, but then I would lose the
sequence of output between console output from the managed code and unmanaged
DLL output.
-- Tom
"William Stacey [MVP]" wrote:
> Hi Thomas. What do you mean by "batch" mode without a window? Calling your
> c# console app from a batch file?
>
> --
> William Stacey [MVP]
>
> "Thomas W. Brown" <thomas_w_brown@xxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:00AE1384-18C6-4357-B51E-7448FFAA9316@xxxxxxxxxxxxxxxx
> >I have setup Console redirection within my Console app (via Console.SetOut
> > and Console.SetErrror) to route console WriteLine calls to a logfile.
> > This
> > works just fine with one exception...
> >
> > I use PInvoke to call into several unmanaged DLLs which write diagnostic
> > information out to stdout (and possibly stderr). When I run in a
> > "standalone" mode with no redirection, these DLLs do generate output to
> > the
> > console window. But I want to run in a "batch" mode where the app is
> > launched without a window. In this mode I still get all Console.WriteLine
> > and Console.Error.WriteLine output properly redirected, but lose all
> > output
> > from the unmanaged DLLs.
> >
> > Is there anything I can do to get output from an unmanaged, PInvoke'd DLL
> > to
> > get redirected properly?
> >
> > Thanks!
> > -- Tom
> >
>
>
>
.
- References:
- How to get stdout/stderr from unmanaged DLL?
- From: Thomas W. Brown
- Re: How to get stdout/stderr from unmanaged DLL?
- From: William Stacey [MVP]
- How to get stdout/stderr from unmanaged DLL?
- Prev by Date: calling C/C++ DLL that takes a pointer to LPTSTR
- Next by Date: Performance Issues
- Previous by thread: Re: How to get stdout/stderr from unmanaged DLL?
- Next by thread: Dynamic DLLImport
- Index(es):
Relevant Pages
|
Loading