loosing Console.WriteLine output after P/Invoke

G

Guest

How come that after a simple P/Invoke call which even does nothing console
output is no longe displayed
My environment:
VS2005
CMD.EXE
pocketconsole (Symbolictools.de)
..NETCF2.0
iPAQ ARM with WM2003 2nd Edition

Appreciate help - isolated the problem so far but guess am stuck now.

tb

c#:
[DllImport("MyUnmanagedC.dll", SetLastError = true)]
private static extern IntPtr netcf_dummy();
// c-lib function: DllExport void netcf_dummy() {}

next Console.WriteLine("this will appear")
netcf_dummy();
next Console.WriteLine("this will not appear anymore")
 
C

Chris Tacke, MVP

Is the second WriteLine ever actually run? Maybe it's not executing to that
point becasue of a problem in the P/Invoke.

-Chris
 
G

Guest

Chris, thanks, that was fast!

Yes, at least the debugger comes back and steps over the line. The
interesting thing is that some following steps that work with the returned
handle also continue to P/Invoke and get correct results back. Only
Console.WriteLine is gone...

I have not figured out how to debug into the unmanaged portions (and
hopefully won'thave to) The DLL is written in plain C, and as I said: just
the function that actually does nothing than returning is killing the output.

tx again - Theo


Chris Tacke said:
Is the second WriteLine ever actually run? Maybe it's not executing to that
point becasue of a problem in the P/Invoke.

-Chris

tb2000 said:
How come that after a simple P/Invoke call which even does nothing console
output is no longe displayed
My environment:
VS2005
CMD.EXE
pocketconsole (Symbolictools.de)
.NETCF2.0
iPAQ ARM with WM2003 2nd Edition

Appreciate help - isolated the problem so far but guess am stuck now.

tb

c#:
[DllImport("MyUnmanagedC.dll", SetLastError = true)]
private static extern IntPtr netcf_dummy();
// c-lib function: DllExport void netcf_dummy() {}

next Console.WriteLine("this will appear")
netcf_dummy();
next Console.WriteLine("this will not appear anymore")
 
G

Guest

One addition:

Trying to isolate the problem in my unmanaged code I found that upon trying
to access I am getting a GetLastError of 0x80000005, apparently something??
prevents access to the handle. This is the code:

static HANDLE hStdout, hStdin;
static DWORD fdwMode, fdwOldMode;
hStdin = GetStdHandle(STD_INPUT_HANDLE);
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
printf("hStdIn=%d hStdOut=%d\n", hStdin, hStdout);
if (!GetConsoleMode(hStdin, &fdwOldMode))
printf("GetConsoleMode - Console Error - GetLastError %x\n",GetLastError());

Strangely when I use my DLL code directly linked to an unmanaged .exe it
works.

???


Is the second WriteLine ever actually run? Maybe it's not executing to that
point becasue of a problem in the P/Invoke.

-Chris

tb2000 said:
How come that after a simple P/Invoke call which even does nothing console
output is no longe displayed
My environment:
VS2005
CMD.EXE
pocketconsole (Symbolictools.de)
.NETCF2.0
iPAQ ARM with WM2003 2nd Edition

Appreciate help - isolated the problem so far but guess am stuck now.

tb

c#:
[DllImport("MyUnmanagedC.dll", SetLastError = true)]
private static extern IntPtr netcf_dummy();
// c-lib function: DllExport void netcf_dummy() {}

next Console.WriteLine("this will appear")
netcf_dummy();
next Console.WriteLine("this will not appear anymore")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top