CreateProcess/WaitForSingleObject Infininte does NOT work w/ MS CA

G

Guest

ok, ive read/implemented and read/implemented and read/implemented...
started w/ the opennetcf implementation and it didnt work and people posted
that it didnt work and i saw no soln that did work. i then implemented the
apis and had the same result.

everything works great as long as you dont use MS cab files; the infinite
wait works fine for cabs ive created for our applications but does not work
w/ either of the following MS cabs:
sqlce.wce4.armv4.CAB
netcf.all.wce4.ARMV4.cab

if i specify a wait time (not w/ the code below) it works but that doesnt do
me any good...

is there something about the MS cabs that make this just not work or what?
has anyone found a workaround for this or am i just missing something?
please help!

code:
public class ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 ProcessId;
public Int32 ThreadId;
}
public class runFile
{
[DllImport("CoreDll.DLL", SetLastError=true)]
private extern static
int CreateProcess( String imageName,
String cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
Int32 boolInheritHandles,
Int32 dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
byte [] si,
ProcessInfo pi );

[DllImport("CoreDll.dll")]
private extern static
Int32 GetLastError();

[DllImport("CoreDll.dll")]
private extern static
Int32 WaitForSingleObject( IntPtr Handle,
Int32 Wait);

public static bool CreateProcess(string ExeName,string CmdLine,
ProcessInfo pi) //, bool waitForever)
{
Int32 INFINITE;
unchecked {INFINITE = (int)0xFFFFFFFF;}

if ( pi == null )
pi = new ProcessInfo();
byte [] si = new byte[128];
CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero,
0, 0, IntPtr.Zero, IntPtr.Zero, si, pi);
WaitForSingleObject(pi.hProcess,INFINITE);
return true;
}
}


code trying to use above w/ MS cab:
private void button2_Click(object sender, System.EventArgs e)
{
ProcessInfo pi=new ProcessInfo();
string exe;
string arg;
exe="\\windows\\wceload.exe";
//*MUST* use /delete 0, not /nodelete
arg="/delete 0 \"\\program files\\installer\\sqlce.wce4.armv4.CAB\"";

if (runFile.CreateProcess(exe,arg,pi)) //,true))
}
 
P

Paul G. Tobey [eMVP]

Look at the unit with the Remote Process Viewer and see *if* the process is
exiting. I've never seen a process exit and *not* had the handle signaled.

Paul T.
 
G

Guest

ok, did that and not real surprised by the result. when i start the process,
wceload has 2 threads w/ different ids and the same pid. when the process
hangs, i still have 2 threads but the pids are now different so i expect my
Wait is now waiting for the wrong pid. this behavior is only exhibited when
im running the MS cabs, not when i run my own.

how do i proceed knowing that?

Paul G. Tobey said:
Look at the unit with the Remote Process Viewer and see *if* the process is
exiting. I've never seen a process exit and *not* had the handle signaled.

Paul T.

Tim Raml said:
ok, ive read/implemented and read/implemented and read/implemented...
started w/ the opennetcf implementation and it didnt work and people
posted
that it didnt work and i saw no soln that did work. i then implemented
the
apis and had the same result.

everything works great as long as you dont use MS cab files; the infinite
wait works fine for cabs ive created for our applications but does not
work
w/ either of the following MS cabs:
sqlce.wce4.armv4.CAB
netcf.all.wce4.ARMV4.cab

if i specify a wait time (not w/ the code below) it works but that doesnt
do
me any good...

is there something about the MS cabs that make this just not work or what?
has anyone found a workaround for this or am i just missing something?
please help!

code:
public class ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 ProcessId;
public Int32 ThreadId;
}
public class runFile
{
[DllImport("CoreDll.DLL", SetLastError=true)]
private extern static
int CreateProcess( String imageName,
String cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
Int32 boolInheritHandles,
Int32 dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
byte [] si,
ProcessInfo pi );

[DllImport("CoreDll.dll")]
private extern static
Int32 GetLastError();

[DllImport("CoreDll.dll")]
private extern static
Int32 WaitForSingleObject( IntPtr Handle,
Int32 Wait);

public static bool CreateProcess(string ExeName,string CmdLine,
ProcessInfo pi) //, bool waitForever)
{
Int32 INFINITE;
unchecked {INFINITE = (int)0xFFFFFFFF;}

if ( pi == null )
pi = new ProcessInfo();
byte [] si = new byte[128];
CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero,
0, 0, IntPtr.Zero, IntPtr.Zero, si, pi);
WaitForSingleObject(pi.hProcess,INFINITE);
return true;
}
}


code trying to use above w/ MS cab:
private void button2_Click(object sender, System.EventArgs e)
{
ProcessInfo pi=new ProcessInfo();
string exe;
string arg;
exe="\\windows\\wceload.exe";
//*MUST* use /delete 0, not /nodelete
arg="/delete 0 \"\\program files\\installer\\sqlce.wce4.armv4.CAB\"";

if (runFile.CreateProcess(exe,arg,pi)) //,true))
}
 
P

Paul G. Tobey [eMVP]

We need details on the device that you're using. If it's doing what you
think it's doing, it's a very serious bug in the OS. I think that's
unlikely, but we'd need to know where to look first...

Paul T.

Tim Raml said:
ok, did that and not real surprised by the result. when i start the
process,
wceload has 2 threads w/ different ids and the same pid. when the process
hangs, i still have 2 threads but the pids are now different so i expect
my
Wait is now waiting for the wrong pid. this behavior is only exhibited
when
im running the MS cabs, not when i run my own.

how do i proceed knowing that?

Paul G. Tobey said:
Look at the unit with the Remote Process Viewer and see *if* the process
is
exiting. I've never seen a process exit and *not* had the handle
signaled.

Paul T.

Tim Raml said:
ok, ive read/implemented and read/implemented and read/implemented...
started w/ the opennetcf implementation and it didnt work and people
posted
that it didnt work and i saw no soln that did work. i then implemented
the
apis and had the same result.

everything works great as long as you dont use MS cab files; the
infinite
wait works fine for cabs ive created for our applications but does not
work
w/ either of the following MS cabs:
sqlce.wce4.armv4.CAB
netcf.all.wce4.ARMV4.cab

if i specify a wait time (not w/ the code below) it works but that
doesnt
do
me any good...

is there something about the MS cabs that make this just not work or
what?
has anyone found a workaround for this or am i just missing something?
please help!

code:
public class ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 ProcessId;
public Int32 ThreadId;
}
public class runFile
{
[DllImport("CoreDll.DLL", SetLastError=true)]
private extern static
int CreateProcess( String imageName,
String cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
Int32 boolInheritHandles,
Int32 dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
byte [] si,
ProcessInfo pi );

[DllImport("CoreDll.dll")]
private extern static
Int32 GetLastError();

[DllImport("CoreDll.dll")]
private extern static
Int32 WaitForSingleObject( IntPtr Handle,
Int32 Wait);

public static bool CreateProcess(string ExeName,string CmdLine,
ProcessInfo pi) //, bool waitForever)
{
Int32 INFINITE;
unchecked {INFINITE = (int)0xFFFFFFFF;}

if ( pi == null )
pi = new ProcessInfo();
byte [] si = new byte[128];
CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero,
0, 0, IntPtr.Zero, IntPtr.Zero, si, pi);
WaitForSingleObject(pi.hProcess,INFINITE);
return true;
}
}


code trying to use above w/ MS cab:
private void button2_Click(object sender, System.EventArgs e)
{
ProcessInfo pi=new ProcessInfo();
string exe;
string arg;
exe="\\windows\\wceload.exe";
//*MUST* use /delete 0, not /nodelete
arg="/delete 0 \"\\program files\\installer\\sqlce.wce4.armv4.CAB\"";

if (runFile.CreateProcess(exe,arg,pi)) //,true))
}
 
G

Guest

Thanks for responding. I am using C# in VS2003 w/ the v1.1 framework. I've
probably got 10 different PPCs I could test on but this problem is presently
exhibiting itself on the 2 I am currently using: iPax h1940 and the hx2110.
I can only assume the others I have will have the same problem.

What else do you want to know?

Paul G. Tobey said:
We need details on the device that you're using. If it's doing what you
think it's doing, it's a very serious bug in the OS. I think that's
unlikely, but we'd need to know where to look first...

Paul T.

Tim Raml said:
ok, did that and not real surprised by the result. when i start the
process,
wceload has 2 threads w/ different ids and the same pid. when the process
hangs, i still have 2 threads but the pids are now different so i expect
my
Wait is now waiting for the wrong pid. this behavior is only exhibited
when
im running the MS cabs, not when i run my own.

how do i proceed knowing that?

Paul G. Tobey said:
Look at the unit with the Remote Process Viewer and see *if* the process
is
exiting. I've never seen a process exit and *not* had the handle
signaled.

Paul T.

ok, ive read/implemented and read/implemented and read/implemented...
started w/ the opennetcf implementation and it didnt work and people
posted
that it didnt work and i saw no soln that did work. i then implemented
the
apis and had the same result.

everything works great as long as you dont use MS cab files; the
infinite
wait works fine for cabs ive created for our applications but does not
work
w/ either of the following MS cabs:
sqlce.wce4.armv4.CAB
netcf.all.wce4.ARMV4.cab

if i specify a wait time (not w/ the code below) it works but that
doesnt
do
me any good...

is there something about the MS cabs that make this just not work or
what?
has anyone found a workaround for this or am i just missing something?
please help!

code:
public class ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 ProcessId;
public Int32 ThreadId;
}
public class runFile
{
[DllImport("CoreDll.DLL", SetLastError=true)]
private extern static
int CreateProcess( String imageName,
String cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
Int32 boolInheritHandles,
Int32 dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
byte [] si,
ProcessInfo pi );

[DllImport("CoreDll.dll")]
private extern static
Int32 GetLastError();

[DllImport("CoreDll.dll")]
private extern static
Int32 WaitForSingleObject( IntPtr Handle,
Int32 Wait);

public static bool CreateProcess(string ExeName,string CmdLine,
ProcessInfo pi) //, bool waitForever)
{
Int32 INFINITE;
unchecked {INFINITE = (int)0xFFFFFFFF;}

if ( pi == null )
pi = new ProcessInfo();
byte [] si = new byte[128];
CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero,
0, 0, IntPtr.Zero, IntPtr.Zero, si, pi);
WaitForSingleObject(pi.hProcess,INFINITE);
return true;
}
}


code trying to use above w/ MS cab:
private void button2_Click(object sender, System.EventArgs e)
{
ProcessInfo pi=new ProcessInfo();
string exe;
string arg;
exe="\\windows\\wceload.exe";
//*MUST* use /delete 0, not /nodelete
arg="/delete 0 \"\\program files\\installer\\sqlce.wce4.armv4.CAB\"";

if (runFile.CreateProcess(exe,arg,pi)) //,true))
}
 
P

Paul G. Tobey [eMVP]

Ah, there's no v1.1 Compact Framework, so that can't be the right
information.

We need to know the version of Pocket PC that you're running into this with.
Pocket PC 2000, 2002, 2003, and/or 2003 Second Edition, so we know what
version of Windows CE they're based on. The chances of getting a fix, if
it's only the 2000 or 2002 editions, are pretty low, so I'd concentrate on
2003 and 2003SE, if possible.

It would also be a very good idea to try duplicating it in native code with
C. Just generate a simple Windows application (not Hello, World), with the
new project wizard in eVC. In WinMain(), call CreateProcess() and
WaitForSingleObject() (and, of course, CloseHandle() on the process handle
after you're done waiting on it).

Report back and post the C code that you use, if it happens with native
code, too, and I'll try it on a couple of devices that I have here.

Paul T.

Tim Raml said:
Thanks for responding. I am using C# in VS2003 w/ the v1.1 framework.
I've
probably got 10 different PPCs I could test on but this problem is
presently
exhibiting itself on the 2 I am currently using: iPax h1940 and the
hx2110.
I can only assume the others I have will have the same problem.

What else do you want to know?

Paul G. Tobey said:
We need details on the device that you're using. If it's doing what you
think it's doing, it's a very serious bug in the OS. I think that's
unlikely, but we'd need to know where to look first...

Paul T.

Tim Raml said:
ok, did that and not real surprised by the result. when i start the
process,
wceload has 2 threads w/ different ids and the same pid. when the
process
hangs, i still have 2 threads but the pids are now different so i
expect
my
Wait is now waiting for the wrong pid. this behavior is only exhibited
when
im running the MS cabs, not when i run my own.

how do i proceed knowing that?

:

Look at the unit with the Remote Process Viewer and see *if* the
process
is
exiting. I've never seen a process exit and *not* had the handle
signaled.

Paul T.

ok, ive read/implemented and read/implemented and
read/implemented...
started w/ the opennetcf implementation and it didnt work and people
posted
that it didnt work and i saw no soln that did work. i then
implemented
the
apis and had the same result.

everything works great as long as you dont use MS cab files; the
infinite
wait works fine for cabs ive created for our applications but does
not
work
w/ either of the following MS cabs:
sqlce.wce4.armv4.CAB
netcf.all.wce4.ARMV4.cab

if i specify a wait time (not w/ the code below) it works but that
doesnt
do
me any good...

is there something about the MS cabs that make this just not work or
what?
has anyone found a workaround for this or am i just missing
something?
please help!

code:
public class ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 ProcessId;
public Int32 ThreadId;
}
public class runFile
{
[DllImport("CoreDll.DLL", SetLastError=true)]
private extern static
int CreateProcess( String imageName,
String cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
Int32 boolInheritHandles,
Int32 dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
byte [] si,
ProcessInfo pi );

[DllImport("CoreDll.dll")]
private extern static
Int32 GetLastError();

[DllImport("CoreDll.dll")]
private extern static
Int32 WaitForSingleObject( IntPtr Handle,
Int32 Wait);

public static bool CreateProcess(string ExeName,string CmdLine,
ProcessInfo pi) //, bool waitForever)
{
Int32 INFINITE;
unchecked {INFINITE = (int)0xFFFFFFFF;}

if ( pi == null )
pi = new ProcessInfo();
byte [] si = new byte[128];
CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero,
0, 0, IntPtr.Zero, IntPtr.Zero, si, pi);
WaitForSingleObject(pi.hProcess,INFINITE);
return true;
}
}


code trying to use above w/ MS cab:
private void button2_Click(object sender, System.EventArgs e)
{
ProcessInfo pi=new ProcessInfo();
string exe;
string arg;
exe="\\windows\\wceload.exe";
//*MUST* use /delete 0, not /nodelete
arg="/delete 0 \"\\program
files\\installer\\sqlce.wce4.armv4.CAB\"";

if (runFile.CreateProcess(exe,arg,pi)) //,true))
}
 
G

Guest

apologies in advance...
1) v1.0.5000 to be more precise
2) iPaq h1940 -Microsoft Pocket PC v4.20.0 (Build 14053)
3) hx2110 - Windows Mobile 2003 Second Edition v4.21.1088 (Build 14132)
4) i dont know c, im using c#
5) i pasted code and provided the names of 2 cabs built and provided by ms
that demonstarte it not working. the pasted code works for cabs that i build
using the tools that were provided by ms.
6) if this is in fact a problem, the chances of it getting fixed in a
timeframe relevant to my schedule is zero...

/me wanders off and tries to implement it in evb, its gotta work in that...

Paul G. Tobey said:
Ah, there's no v1.1 Compact Framework, so that can't be the right
information.

We need to know the version of Pocket PC that you're running into this with.
Pocket PC 2000, 2002, 2003, and/or 2003 Second Edition, so we know what
version of Windows CE they're based on. The chances of getting a fix, if
it's only the 2000 or 2002 editions, are pretty low, so I'd concentrate on
2003 and 2003SE, if possible.

It would also be a very good idea to try duplicating it in native code with
C. Just generate a simple Windows application (not Hello, World), with the
new project wizard in eVC. In WinMain(), call CreateProcess() and
WaitForSingleObject() (and, of course, CloseHandle() on the process handle
after you're done waiting on it).

Report back and post the C code that you use, if it happens with native
code, too, and I'll try it on a couple of devices that I have here.

Paul T.

Tim Raml said:
Thanks for responding. I am using C# in VS2003 w/ the v1.1 framework.
I've
probably got 10 different PPCs I could test on but this problem is
presently
exhibiting itself on the 2 I am currently using: iPax h1940 and the
hx2110.
I can only assume the others I have will have the same problem.

What else do you want to know?

Paul G. Tobey said:
We need details on the device that you're using. If it's doing what you
think it's doing, it's a very serious bug in the OS. I think that's
unlikely, but we'd need to know where to look first...

Paul T.

ok, did that and not real surprised by the result. when i start the
process,
wceload has 2 threads w/ different ids and the same pid. when the
process
hangs, i still have 2 threads but the pids are now different so i
expect
my
Wait is now waiting for the wrong pid. this behavior is only exhibited
when
im running the MS cabs, not when i run my own.

how do i proceed knowing that?

:

Look at the unit with the Remote Process Viewer and see *if* the
process
is
exiting. I've never seen a process exit and *not* had the handle
signaled.

Paul T.

ok, ive read/implemented and read/implemented and
read/implemented...
started w/ the opennetcf implementation and it didnt work and people
posted
that it didnt work and i saw no soln that did work. i then
implemented
the
apis and had the same result.

everything works great as long as you dont use MS cab files; the
infinite
wait works fine for cabs ive created for our applications but does
not
work
w/ either of the following MS cabs:
sqlce.wce4.armv4.CAB
netcf.all.wce4.ARMV4.cab

if i specify a wait time (not w/ the code below) it works but that
doesnt
do
me any good...

is there something about the MS cabs that make this just not work or
what?
has anyone found a workaround for this or am i just missing
something?
please help!

code:
public class ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 ProcessId;
public Int32 ThreadId;
}
public class runFile
{
[DllImport("CoreDll.DLL", SetLastError=true)]
private extern static
int CreateProcess( String imageName,
String cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
Int32 boolInheritHandles,
Int32 dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
byte [] si,
ProcessInfo pi );

[DllImport("CoreDll.dll")]
private extern static
Int32 GetLastError();

[DllImport("CoreDll.dll")]
private extern static
Int32 WaitForSingleObject( IntPtr Handle,
Int32 Wait);

public static bool CreateProcess(string ExeName,string CmdLine,
ProcessInfo pi) //, bool waitForever)
{
Int32 INFINITE;
unchecked {INFINITE = (int)0xFFFFFFFF;}

if ( pi == null )
pi = new ProcessInfo();
byte [] si = new byte[128];
CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero,
0, 0, IntPtr.Zero, IntPtr.Zero, si, pi);
WaitForSingleObject(pi.hProcess,INFINITE);
return true;
}
}


code trying to use above w/ MS cab:
private void button2_Click(object sender, System.EventArgs e)
{
ProcessInfo pi=new ProcessInfo();
string exe;
string arg;
exe="\\windows\\wceload.exe";
//*MUST* use /delete 0, not /nodelete
arg="/delete 0 \"\\program
files\\installer\\sqlce.wce4.armv4.CAB\"";

if (runFile.CreateProcess(exe,arg,pi)) //,true))
}
 
P

Paul G. Tobey [eMVP]

1. Sounds right.

2/3. Excellent. There's a chance, if it is an OS bug, maybe.

4. If you can write in C# and read those P/Invoke declarations, I'd say that
you *can* program in C. We have to eliminate the managed environment as the
cause of the problem and C is really the only good way (and the most
consistent with the code you're already writing -- 10 minutes should allow
you to port what you've got to C).

5. That's perfect.

6. Probably, yes, but MS might also be able to offer some type of a
work-around that would fit with the schedule.

Paul T.

Tim Raml said:
apologies in advance...
1) v1.0.5000 to be more precise
2) iPaq h1940 -Microsoft Pocket PC v4.20.0 (Build 14053)
3) hx2110 - Windows Mobile 2003 Second Edition v4.21.1088 (Build 14132)
4) i dont know c, im using c#
5) i pasted code and provided the names of 2 cabs built and provided by ms
that demonstarte it not working. the pasted code works for cabs that i
build
using the tools that were provided by ms.
6) if this is in fact a problem, the chances of it getting fixed in a
timeframe relevant to my schedule is zero...

/me wanders off and tries to implement it in evb, its gotta work in
that...

Paul G. Tobey said:
Ah, there's no v1.1 Compact Framework, so that can't be the right
information.

We need to know the version of Pocket PC that you're running into this
with.
Pocket PC 2000, 2002, 2003, and/or 2003 Second Edition, so we know what
version of Windows CE they're based on. The chances of getting a fix, if
it's only the 2000 or 2002 editions, are pretty low, so I'd concentrate
on
2003 and 2003SE, if possible.

It would also be a very good idea to try duplicating it in native code
with
C. Just generate a simple Windows application (not Hello, World), with
the
new project wizard in eVC. In WinMain(), call CreateProcess() and
WaitForSingleObject() (and, of course, CloseHandle() on the process
handle
after you're done waiting on it).

Report back and post the C code that you use, if it happens with native
code, too, and I'll try it on a couple of devices that I have here.

Paul T.

Tim Raml said:
Thanks for responding. I am using C# in VS2003 w/ the v1.1 framework.
I've
probably got 10 different PPCs I could test on but this problem is
presently
exhibiting itself on the 2 I am currently using: iPax h1940 and the
hx2110.
I can only assume the others I have will have the same problem.

What else do you want to know?

:

We need details on the device that you're using. If it's doing what
you
think it's doing, it's a very serious bug in the OS. I think that's
unlikely, but we'd need to know where to look first...

Paul T.

ok, did that and not real surprised by the result. when i start the
process,
wceload has 2 threads w/ different ids and the same pid. when the
process
hangs, i still have 2 threads but the pids are now different so i
expect
my
Wait is now waiting for the wrong pid. this behavior is only
exhibited
when
im running the MS cabs, not when i run my own.

how do i proceed knowing that?

:

Look at the unit with the Remote Process Viewer and see *if* the
process
is
exiting. I've never seen a process exit and *not* had the handle
signaled.

Paul T.

ok, ive read/implemented and read/implemented and
read/implemented...
started w/ the opennetcf implementation and it didnt work and
people
posted
that it didnt work and i saw no soln that did work. i then
implemented
the
apis and had the same result.

everything works great as long as you dont use MS cab files; the
infinite
wait works fine for cabs ive created for our applications but
does
not
work
w/ either of the following MS cabs:
sqlce.wce4.armv4.CAB
netcf.all.wce4.ARMV4.cab

if i specify a wait time (not w/ the code below) it works but
that
doesnt
do
me any good...

is there something about the MS cabs that make this just not work
or
what?
has anyone found a workaround for this or am i just missing
something?
please help!

code:
public class ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 ProcessId;
public Int32 ThreadId;
}
public class runFile
{
[DllImport("CoreDll.DLL", SetLastError=true)]
private extern static
int CreateProcess( String imageName,
String cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
Int32 boolInheritHandles,
Int32 dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
byte [] si,
ProcessInfo pi );

[DllImport("CoreDll.dll")]
private extern static
Int32 GetLastError();

[DllImport("CoreDll.dll")]
private extern static
Int32 WaitForSingleObject( IntPtr Handle,
Int32 Wait);

public static bool CreateProcess(string ExeName,string CmdLine,
ProcessInfo pi) //, bool waitForever)
{
Int32 INFINITE;
unchecked {INFINITE = (int)0xFFFFFFFF;}

if ( pi == null )
pi = new ProcessInfo();
byte [] si = new byte[128];
CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero,
0, 0, IntPtr.Zero, IntPtr.Zero, si, pi);
WaitForSingleObject(pi.hProcess,INFINITE);
return true;
}
}


code trying to use above w/ MS cab:
private void button2_Click(object sender, System.EventArgs e)
{
ProcessInfo pi=new ProcessInfo();
string exe;
string arg;
exe="\\windows\\wceload.exe";
//*MUST* use /delete 0, not /nodelete
arg="/delete 0 \"\\program
files\\installer\\sqlce.wce4.armv4.CAB\"";

if (runFile.CreateProcess(exe,arg,pi)) //,true))
}
 
A

Alex Feinman [MVP]

I've seen this problem before. What worked for me is using ShellExecuteEx
instead of CreateProcess. You need to set flag SEE_MASK_NOCLOSEPROCESS in
order to get a valid hProcess to wait for.

If you want to see C++ code, send me an email. Sorry, I don't have anything
C# handy but it should be trivial

--
Alex Feinman
---
Visit http://www.opennetcf.org
Tim Raml said:
apologies in advance...
1) v1.0.5000 to be more precise
2) iPaq h1940 -Microsoft Pocket PC v4.20.0 (Build 14053)
3) hx2110 - Windows Mobile 2003 Second Edition v4.21.1088 (Build 14132)
4) i dont know c, im using c#
5) i pasted code and provided the names of 2 cabs built and provided by ms
that demonstarte it not working. the pasted code works for cabs that i
build
using the tools that were provided by ms.
6) if this is in fact a problem, the chances of it getting fixed in a
timeframe relevant to my schedule is zero...

/me wanders off and tries to implement it in evb, its gotta work in
that...

Paul G. Tobey said:
Ah, there's no v1.1 Compact Framework, so that can't be the right
information.

We need to know the version of Pocket PC that you're running into this
with.
Pocket PC 2000, 2002, 2003, and/or 2003 Second Edition, so we know what
version of Windows CE they're based on. The chances of getting a fix, if
it's only the 2000 or 2002 editions, are pretty low, so I'd concentrate
on
2003 and 2003SE, if possible.

It would also be a very good idea to try duplicating it in native code
with
C. Just generate a simple Windows application (not Hello, World), with
the
new project wizard in eVC. In WinMain(), call CreateProcess() and
WaitForSingleObject() (and, of course, CloseHandle() on the process
handle
after you're done waiting on it).

Report back and post the C code that you use, if it happens with native
code, too, and I'll try it on a couple of devices that I have here.

Paul T.

Tim Raml said:
Thanks for responding. I am using C# in VS2003 w/ the v1.1 framework.
I've
probably got 10 different PPCs I could test on but this problem is
presently
exhibiting itself on the 2 I am currently using: iPax h1940 and the
hx2110.
I can only assume the others I have will have the same problem.

What else do you want to know?

:

We need details on the device that you're using. If it's doing what
you
think it's doing, it's a very serious bug in the OS. I think that's
unlikely, but we'd need to know where to look first...

Paul T.

ok, did that and not real surprised by the result. when i start the
process,
wceload has 2 threads w/ different ids and the same pid. when the
process
hangs, i still have 2 threads but the pids are now different so i
expect
my
Wait is now waiting for the wrong pid. this behavior is only
exhibited
when
im running the MS cabs, not when i run my own.

how do i proceed knowing that?

:

Look at the unit with the Remote Process Viewer and see *if* the
process
is
exiting. I've never seen a process exit and *not* had the handle
signaled.

Paul T.

ok, ive read/implemented and read/implemented and
read/implemented...
started w/ the opennetcf implementation and it didnt work and
people
posted
that it didnt work and i saw no soln that did work. i then
implemented
the
apis and had the same result.

everything works great as long as you dont use MS cab files; the
infinite
wait works fine for cabs ive created for our applications but
does
not
work
w/ either of the following MS cabs:
sqlce.wce4.armv4.CAB
netcf.all.wce4.ARMV4.cab

if i specify a wait time (not w/ the code below) it works but
that
doesnt
do
me any good...

is there something about the MS cabs that make this just not work
or
what?
has anyone found a workaround for this or am i just missing
something?
please help!

code:
public class ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 ProcessId;
public Int32 ThreadId;
}
public class runFile
{
[DllImport("CoreDll.DLL", SetLastError=true)]
private extern static
int CreateProcess( String imageName,
String cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
Int32 boolInheritHandles,
Int32 dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
byte [] si,
ProcessInfo pi );

[DllImport("CoreDll.dll")]
private extern static
Int32 GetLastError();

[DllImport("CoreDll.dll")]
private extern static
Int32 WaitForSingleObject( IntPtr Handle,
Int32 Wait);

public static bool CreateProcess(string ExeName,string CmdLine,
ProcessInfo pi) //, bool waitForever)
{
Int32 INFINITE;
unchecked {INFINITE = (int)0xFFFFFFFF;}

if ( pi == null )
pi = new ProcessInfo();
byte [] si = new byte[128];
CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero,
0, 0, IntPtr.Zero, IntPtr.Zero, si, pi);
WaitForSingleObject(pi.hProcess,INFINITE);
return true;
}
}


code trying to use above w/ MS cab:
private void button2_Click(object sender, System.EventArgs e)
{
ProcessInfo pi=new ProcessInfo();
string exe;
string arg;
exe="\\windows\\wceload.exe";
//*MUST* use /delete 0, not /nodelete
arg="/delete 0 \"\\program
files\\installer\\sqlce.wce4.armv4.CAB\"";

if (runFile.CreateProcess(exe,arg,pi)) //,true))
}
 
P

Paul G. Tobey [eMVP]

Sounds like a possibility. I've also just written a test case in C++ and it
finishes fine for me.

Paul T.

Alex Feinman said:
I've seen this problem before. What worked for me is using ShellExecuteEx
instead of CreateProcess. You need to set flag SEE_MASK_NOCLOSEPROCESS in
order to get a valid hProcess to wait for.

If you want to see C++ code, send me an email. Sorry, I don't have
anything C# handy but it should be trivial

--
Alex Feinman
---
Visit http://www.opennetcf.org
Tim Raml said:
apologies in advance...
1) v1.0.5000 to be more precise
2) iPaq h1940 -Microsoft Pocket PC v4.20.0 (Build 14053)
3) hx2110 - Windows Mobile 2003 Second Edition v4.21.1088 (Build 14132)
4) i dont know c, im using c#
5) i pasted code and provided the names of 2 cabs built and provided by
ms
that demonstarte it not working. the pasted code works for cabs that i
build
using the tools that were provided by ms.
6) if this is in fact a problem, the chances of it getting fixed in a
timeframe relevant to my schedule is zero...

/me wanders off and tries to implement it in evb, its gotta work in
that...

Paul G. Tobey said:
Ah, there's no v1.1 Compact Framework, so that can't be the right
information.

We need to know the version of Pocket PC that you're running into this
with.
Pocket PC 2000, 2002, 2003, and/or 2003 Second Edition, so we know what
version of Windows CE they're based on. The chances of getting a fix,
if
it's only the 2000 or 2002 editions, are pretty low, so I'd concentrate
on
2003 and 2003SE, if possible.

It would also be a very good idea to try duplicating it in native code
with
C. Just generate a simple Windows application (not Hello, World), with
the
new project wizard in eVC. In WinMain(), call CreateProcess() and
WaitForSingleObject() (and, of course, CloseHandle() on the process
handle
after you're done waiting on it).

Report back and post the C code that you use, if it happens with native
code, too, and I'll try it on a couple of devices that I have here.

Paul T.

Thanks for responding. I am using C# in VS2003 w/ the v1.1 framework.
I've
probably got 10 different PPCs I could test on but this problem is
presently
exhibiting itself on the 2 I am currently using: iPax h1940 and the
hx2110.
I can only assume the others I have will have the same problem.

What else do you want to know?

:

We need details on the device that you're using. If it's doing what
you
think it's doing, it's a very serious bug in the OS. I think that's
unlikely, but we'd need to know where to look first...

Paul T.

ok, did that and not real surprised by the result. when i start
the
process,
wceload has 2 threads w/ different ids and the same pid. when the
process
hangs, i still have 2 threads but the pids are now different so i
expect
my
Wait is now waiting for the wrong pid. this behavior is only
exhibited
when
im running the MS cabs, not when i run my own.

how do i proceed knowing that?

:

Look at the unit with the Remote Process Viewer and see *if* the
process
is
exiting. I've never seen a process exit and *not* had the handle
signaled.

Paul T.

ok, ive read/implemented and read/implemented and
read/implemented...
started w/ the opennetcf implementation and it didnt work and
people
posted
that it didnt work and i saw no soln that did work. i then
implemented
the
apis and had the same result.

everything works great as long as you dont use MS cab files; the
infinite
wait works fine for cabs ive created for our applications but
does
not
work
w/ either of the following MS cabs:
sqlce.wce4.armv4.CAB
netcf.all.wce4.ARMV4.cab

if i specify a wait time (not w/ the code below) it works but
that
doesnt
do
me any good...

is there something about the MS cabs that make this just not
work or
what?
has anyone found a workaround for this or am i just missing
something?
please help!

code:
public class ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 ProcessId;
public Int32 ThreadId;
}
public class runFile
{
[DllImport("CoreDll.DLL", SetLastError=true)]
private extern static
int CreateProcess( String imageName,
String cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
Int32 boolInheritHandles,
Int32 dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
byte [] si,
ProcessInfo pi );

[DllImport("CoreDll.dll")]
private extern static
Int32 GetLastError();

[DllImport("CoreDll.dll")]
private extern static
Int32 WaitForSingleObject( IntPtr Handle,
Int32 Wait);

public static bool CreateProcess(string ExeName,string CmdLine,
ProcessInfo pi) //, bool waitForever)
{
Int32 INFINITE;
unchecked {INFINITE = (int)0xFFFFFFFF;}

if ( pi == null )
pi = new ProcessInfo();
byte [] si = new byte[128];
CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero,
0, 0, IntPtr.Zero, IntPtr.Zero, si, pi);
WaitForSingleObject(pi.hProcess,INFINITE);
return true;
}
}


code trying to use above w/ MS cab:
private void button2_Click(object sender, System.EventArgs e)
{
ProcessInfo pi=new ProcessInfo();
string exe;
string arg;
exe="\\windows\\wceload.exe";
//*MUST* use /delete 0, not /nodelete
arg="/delete 0 \"\\program
files\\installer\\sqlce.wce4.armv4.CAB\"";

if (runFile.CreateProcess(exe,arg,pi)) //,true))
}
 
G

Guest

what cab file did you use to test it?

Paul G. Tobey said:
Sounds like a possibility. I've also just written a test case in C++ and it
finishes fine for me.

Paul T.

Alex Feinman said:
I've seen this problem before. What worked for me is using ShellExecuteEx
instead of CreateProcess. You need to set flag SEE_MASK_NOCLOSEPROCESS in
order to get a valid hProcess to wait for.

If you want to see C++ code, send me an email. Sorry, I don't have
anything C# handy but it should be trivial

--
Alex Feinman
---
Visit http://www.opennetcf.org
Tim Raml said:
apologies in advance...
1) v1.0.5000 to be more precise
2) iPaq h1940 -Microsoft Pocket PC v4.20.0 (Build 14053)
3) hx2110 - Windows Mobile 2003 Second Edition v4.21.1088 (Build 14132)
4) i dont know c, im using c#
5) i pasted code and provided the names of 2 cabs built and provided by
ms
that demonstarte it not working. the pasted code works for cabs that i
build
using the tools that were provided by ms.
6) if this is in fact a problem, the chances of it getting fixed in a
timeframe relevant to my schedule is zero...

/me wanders off and tries to implement it in evb, its gotta work in
that...

:

Ah, there's no v1.1 Compact Framework, so that can't be the right
information.

We need to know the version of Pocket PC that you're running into this
with.
Pocket PC 2000, 2002, 2003, and/or 2003 Second Edition, so we know what
version of Windows CE they're based on. The chances of getting a fix,
if
it's only the 2000 or 2002 editions, are pretty low, so I'd concentrate
on
2003 and 2003SE, if possible.

It would also be a very good idea to try duplicating it in native code
with
C. Just generate a simple Windows application (not Hello, World), with
the
new project wizard in eVC. In WinMain(), call CreateProcess() and
WaitForSingleObject() (and, of course, CloseHandle() on the process
handle
after you're done waiting on it).

Report back and post the C code that you use, if it happens with native
code, too, and I'll try it on a couple of devices that I have here.

Paul T.

Thanks for responding. I am using C# in VS2003 w/ the v1.1 framework.
I've
probably got 10 different PPCs I could test on but this problem is
presently
exhibiting itself on the 2 I am currently using: iPax h1940 and the
hx2110.
I can only assume the others I have will have the same problem.

What else do you want to know?

:

We need details on the device that you're using. If it's doing what
you
think it's doing, it's a very serious bug in the OS. I think that's
unlikely, but we'd need to know where to look first...

Paul T.

ok, did that and not real surprised by the result. when i start
the
process,
wceload has 2 threads w/ different ids and the same pid. when the
process
hangs, i still have 2 threads but the pids are now different so i
expect
my
Wait is now waiting for the wrong pid. this behavior is only
exhibited
when
im running the MS cabs, not when i run my own.

how do i proceed knowing that?

:

Look at the unit with the Remote Process Viewer and see *if* the
process
is
exiting. I've never seen a process exit and *not* had the handle
signaled.

Paul T.

ok, ive read/implemented and read/implemented and
read/implemented...
started w/ the opennetcf implementation and it didnt work and
people
posted
that it didnt work and i saw no soln that did work. i then
implemented
the
apis and had the same result.

everything works great as long as you dont use MS cab files; the
infinite
wait works fine for cabs ive created for our applications but
does
not
work
w/ either of the following MS cabs:
sqlce.wce4.armv4.CAB
netcf.all.wce4.ARMV4.cab

if i specify a wait time (not w/ the code below) it works but
that
doesnt
do
me any good...

is there something about the MS cabs that make this just not
work or
what?
has anyone found a workaround for this or am i just missing
something?
please help!

code:
public class ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 ProcessId;
public Int32 ThreadId;
}
public class runFile
{
[DllImport("CoreDll.DLL", SetLastError=true)]
private extern static
int CreateProcess( String imageName,
String cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
Int32 boolInheritHandles,
Int32 dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
byte [] si,
ProcessInfo pi );

[DllImport("CoreDll.dll")]
private extern static
Int32 GetLastError();

[DllImport("CoreDll.dll")]
private extern static
Int32 WaitForSingleObject( IntPtr Handle,
Int32 Wait);

public static bool CreateProcess(string ExeName,string CmdLine,
ProcessInfo pi) //, bool waitForever)
{
Int32 INFINITE;
unchecked {INFINITE = (int)0xFFFFFFFF;}

if ( pi == null )
pi = new ProcessInfo();
byte [] si = new byte[128];
CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero,
0, 0, IntPtr.Zero, IntPtr.Zero, si, pi);
WaitForSingleObject(pi.hProcess,INFINITE);
return true;
}
}


code trying to use above w/ MS cab:
private void button2_Click(object sender, System.EventArgs e)
{
ProcessInfo pi=new ProcessInfo();
string exe;
string arg;
exe="\\windows\\wceload.exe";
//*MUST* use /delete 0, not /nodelete
arg="/delete 0 \"\\program
files\\installer\\sqlce.wce4.armv4.CAB\"";

if (runFile.CreateProcess(exe,arg,pi)) //,true))
}
 
P

Paul G. Tobey [eMVP]

Both of the ones that you referenced in your first post, actually (I wrote
version that pops up a dialog and asks what you want to try).

I think that we have an "interesting situation" in the .NET CF run-time,
rather than, strictly, a bug. You're trying to install a cab that replaces
some of the files that you are in the process or using, maybe?

Paul T.

Tim Raml said:
what cab file did you use to test it?

Paul G. Tobey said:
Sounds like a possibility. I've also just written a test case in C++ and
it
finishes fine for me.

Paul T.

Alex Feinman said:
I've seen this problem before. What worked for me is using
ShellExecuteEx
instead of CreateProcess. You need to set flag SEE_MASK_NOCLOSEPROCESS
in
order to get a valid hProcess to wait for.

If you want to see C++ code, send me an email. Sorry, I don't have
anything C# handy but it should be trivial

--
Alex Feinman
---
Visit http://www.opennetcf.org
apologies in advance...
1) v1.0.5000 to be more precise
2) iPaq h1940 -Microsoft Pocket PC v4.20.0 (Build 14053)
3) hx2110 - Windows Mobile 2003 Second Edition v4.21.1088 (Build
14132)
4) i dont know c, im using c#
5) i pasted code and provided the names of 2 cabs built and provided
by
ms
that demonstarte it not working. the pasted code works for cabs that
i
build
using the tools that were provided by ms.
6) if this is in fact a problem, the chances of it getting fixed in a
timeframe relevant to my schedule is zero...

/me wanders off and tries to implement it in evb, its gotta work in
that...

:

Ah, there's no v1.1 Compact Framework, so that can't be the right
information.

We need to know the version of Pocket PC that you're running into
this
with.
Pocket PC 2000, 2002, 2003, and/or 2003 Second Edition, so we know
what
version of Windows CE they're based on. The chances of getting a
fix,
if
it's only the 2000 or 2002 editions, are pretty low, so I'd
concentrate
on
2003 and 2003SE, if possible.

It would also be a very good idea to try duplicating it in native
code
with
C. Just generate a simple Windows application (not Hello, World),
with
the
new project wizard in eVC. In WinMain(), call CreateProcess() and
WaitForSingleObject() (and, of course, CloseHandle() on the process
handle
after you're done waiting on it).

Report back and post the C code that you use, if it happens with
native
code, too, and I'll try it on a couple of devices that I have here.

Paul T.

Thanks for responding. I am using C# in VS2003 w/ the v1.1
framework.
I've
probably got 10 different PPCs I could test on but this problem is
presently
exhibiting itself on the 2 I am currently using: iPax h1940 and the
hx2110.
I can only assume the others I have will have the same problem.

What else do you want to know?

:

We need details on the device that you're using. If it's doing
what
you
think it's doing, it's a very serious bug in the OS. I think
that's
unlikely, but we'd need to know where to look first...

Paul T.

ok, did that and not real surprised by the result. when i start
the
process,
wceload has 2 threads w/ different ids and the same pid. when
the
process
hangs, i still have 2 threads but the pids are now different so
i
expect
my
Wait is now waiting for the wrong pid. this behavior is only
exhibited
when
im running the MS cabs, not when i run my own.

how do i proceed knowing that?

:

Look at the unit with the Remote Process Viewer and see *if*
the
process
is
exiting. I've never seen a process exit and *not* had the
handle
signaled.

Paul T.

ok, ive read/implemented and read/implemented and
read/implemented...
started w/ the opennetcf implementation and it didnt work and
people
posted
that it didnt work and i saw no soln that did work. i then
implemented
the
apis and had the same result.

everything works great as long as you dont use MS cab files;
the
infinite
wait works fine for cabs ive created for our applications but
does
not
work
w/ either of the following MS cabs:
sqlce.wce4.armv4.CAB
netcf.all.wce4.ARMV4.cab

if i specify a wait time (not w/ the code below) it works but
that
doesnt
do
me any good...

is there something about the MS cabs that make this just not
work or
what?
has anyone found a workaround for this or am i just missing
something?
please help!

code:
public class ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 ProcessId;
public Int32 ThreadId;
}
public class runFile
{
[DllImport("CoreDll.DLL", SetLastError=true)]
private extern static
int CreateProcess( String imageName,
String cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
Int32 boolInheritHandles,
Int32 dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
byte [] si,
ProcessInfo pi );

[DllImport("CoreDll.dll")]
private extern static
Int32 GetLastError();

[DllImport("CoreDll.dll")]
private extern static
Int32 WaitForSingleObject( IntPtr Handle,
Int32 Wait);

public static bool CreateProcess(string ExeName,string
CmdLine,
ProcessInfo pi) //, bool waitForever)
{
Int32 INFINITE;
unchecked {INFINITE = (int)0xFFFFFFFF;}

if ( pi == null )
pi = new ProcessInfo();
byte [] si = new byte[128];
CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero,
0, 0, IntPtr.Zero, IntPtr.Zero, si, pi);
WaitForSingleObject(pi.hProcess,INFINITE);
return true;
}
}


code trying to use above w/ MS cab:
private void button2_Click(object sender, System.EventArgs e)
{
ProcessInfo pi=new ProcessInfo();
string exe;
string arg;
exe="\\windows\\wceload.exe";
//*MUST* use /delete 0, not /nodelete
arg="/delete 0 \"\\program
files\\installer\\sqlce.wce4.armv4.CAB\"";

if (runFile.CreateProcess(exe,arg,pi)) //,true))
}
 
G

Guest

i replaced createprocess w/ shellexecuteex
(http://www.opennetcf.org/Forums/topic.asp?TOPIC_ID=263) and i get the same
hanging result w/ the ms cab file -> sqlce.wce4.armv4.CAB
it works fine for a cab ive created, just as createprocess did.

string docname="\\windows\\wceload.exe";
string param="/delete 0 \"\\program
files\\installer\\sqlce.wce4.armv4.CAB\"";

int nSize = docname.Length * 2 + 2;
IntPtr pData = SHELLEXECUTEEX.LocalAlloc(0x40, nSize);
System.Runtime.InteropServices.Marshal.Copy(System.Text.Encoding.Unicode.GetBytes(docname), 0, pData, nSize - 2);

nSize=param.Length*2+1;
IntPtr pParam=SHELLEXECUTEEX.LocalAlloc(0x40, nSize);
System.Runtime.InteropServices.Marshal.Copy(System.Text.Encoding.Unicode.GetBytes(param), 0, pParam, nSize - 2);

SHELLEXECUTEEX see = new SHELLEXECUTEEX();
see.cbSize = 60;
see.dwHotKey = 0;
see.fMask = 0x40; //0; //Public Const SEE_MASK_NOCLOSEPROCESS = &H40
see.hIcon = IntPtr.Zero;
see.hInstApp = IntPtr.Zero;
see.hProcess = IntPtr.Zero;;
see.lpClass = IntPtr.Zero;
see.lpDirectory = IntPtr.Zero;
see.lpIDList = IntPtr.Zero;
//see.lpParameters = IntPtr.Zero;
see.lpParameters = pParam;
see.lpVerb = IntPtr.Zero;
see.nShow = 0;
see.lpFile = pData;

SHELLEXECUTEEX.ShellExecuteEx(see);

Int32 INFINITE;
unchecked {INFINITE = (int)0xFFFFFFFF;}
runFile.WaitForSingleObject(see.hProcess,INFINITE);

SHELLEXECUTEEX.LocalFree(pData);
SHELLEXECUTEEX.LocalFree(pParam);

Alex Feinman said:
I've seen this problem before. What worked for me is using ShellExecuteEx
instead of CreateProcess. You need to set flag SEE_MASK_NOCLOSEPROCESS in
order to get a valid hProcess to wait for.

If you want to see C++ code, send me an email. Sorry, I don't have anything
C# handy but it should be trivial

--
Alex Feinman
---
Visit http://www.opennetcf.org
Tim Raml said:
apologies in advance...
1) v1.0.5000 to be more precise
2) iPaq h1940 -Microsoft Pocket PC v4.20.0 (Build 14053)
3) hx2110 - Windows Mobile 2003 Second Edition v4.21.1088 (Build 14132)
4) i dont know c, im using c#
5) i pasted code and provided the names of 2 cabs built and provided by ms
that demonstarte it not working. the pasted code works for cabs that i
build
using the tools that were provided by ms.
6) if this is in fact a problem, the chances of it getting fixed in a
timeframe relevant to my schedule is zero...

/me wanders off and tries to implement it in evb, its gotta work in
that...

Paul G. Tobey said:
Ah, there's no v1.1 Compact Framework, so that can't be the right
information.

We need to know the version of Pocket PC that you're running into this
with.
Pocket PC 2000, 2002, 2003, and/or 2003 Second Edition, so we know what
version of Windows CE they're based on. The chances of getting a fix, if
it's only the 2000 or 2002 editions, are pretty low, so I'd concentrate
on
2003 and 2003SE, if possible.

It would also be a very good idea to try duplicating it in native code
with
C. Just generate a simple Windows application (not Hello, World), with
the
new project wizard in eVC. In WinMain(), call CreateProcess() and
WaitForSingleObject() (and, of course, CloseHandle() on the process
handle
after you're done waiting on it).

Report back and post the C code that you use, if it happens with native
code, too, and I'll try it on a couple of devices that I have here.

Paul T.

Thanks for responding. I am using C# in VS2003 w/ the v1.1 framework.
I've
probably got 10 different PPCs I could test on but this problem is
presently
exhibiting itself on the 2 I am currently using: iPax h1940 and the
hx2110.
I can only assume the others I have will have the same problem.

What else do you want to know?

:

We need details on the device that you're using. If it's doing what
you
think it's doing, it's a very serious bug in the OS. I think that's
unlikely, but we'd need to know where to look first...

Paul T.

ok, did that and not real surprised by the result. when i start the
process,
wceload has 2 threads w/ different ids and the same pid. when the
process
hangs, i still have 2 threads but the pids are now different so i
expect
my
Wait is now waiting for the wrong pid. this behavior is only
exhibited
when
im running the MS cabs, not when i run my own.

how do i proceed knowing that?

:

Look at the unit with the Remote Process Viewer and see *if* the
process
is
exiting. I've never seen a process exit and *not* had the handle
signaled.

Paul T.

ok, ive read/implemented and read/implemented and
read/implemented...
started w/ the opennetcf implementation and it didnt work and
people
posted
that it didnt work and i saw no soln that did work. i then
implemented
the
apis and had the same result.

everything works great as long as you dont use MS cab files; the
infinite
wait works fine for cabs ive created for our applications but
does
not
work
w/ either of the following MS cabs:
sqlce.wce4.armv4.CAB
netcf.all.wce4.ARMV4.cab

if i specify a wait time (not w/ the code below) it works but
that
doesnt
do
me any good...

is there something about the MS cabs that make this just not work
or
what?
has anyone found a workaround for this or am i just missing
something?
please help!

code:
public class ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 ProcessId;
public Int32 ThreadId;
}
public class runFile
{
[DllImport("CoreDll.DLL", SetLastError=true)]
private extern static
int CreateProcess( String imageName,
String cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
Int32 boolInheritHandles,
Int32 dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
byte [] si,
ProcessInfo pi );

[DllImport("CoreDll.dll")]
private extern static
Int32 GetLastError();

[DllImport("CoreDll.dll")]
private extern static
Int32 WaitForSingleObject( IntPtr Handle,
Int32 Wait);

public static bool CreateProcess(string ExeName,string CmdLine,
ProcessInfo pi) //, bool waitForever)
{
Int32 INFINITE;
unchecked {INFINITE = (int)0xFFFFFFFF;}

if ( pi == null )
pi = new ProcessInfo();
byte [] si = new byte[128];
CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero,
0, 0, IntPtr.Zero, IntPtr.Zero, si, pi);
WaitForSingleObject(pi.hProcess,INFINITE);
return true;
}
}


code trying to use above w/ MS cab:
private void button2_Click(object sender, System.EventArgs e)
{
ProcessInfo pi=new ProcessInfo();
string exe;
string arg;
exe="\\windows\\wceload.exe";
//*MUST* use /delete 0, not /nodelete
arg="/delete 0 \"\\program
files\\installer\\sqlce.wce4.armv4.CAB\"";

if (runFile.CreateProcess(exe,arg,pi)) //,true))
}
 
G

Guest

yes, i realize im trying to install the cf while im running a cf app but for
that i wasnt going to wait for the proc to finish, i was just going to
terminate my app (which may have consequences of its own, havent gotten that
far).

thats not an issue w/ sqlce.wce4.armv4.CAB, its not even installed on the
device and it hangs at the end just as the cf install does when using
createprocess/wait...

if you have a compiled app i can run on my ppc to test, email it, id love to
test it here and provide you the results.

Paul G. Tobey said:
Both of the ones that you referenced in your first post, actually (I wrote
version that pops up a dialog and asks what you want to try).

I think that we have an "interesting situation" in the .NET CF run-time,
rather than, strictly, a bug. You're trying to install a cab that replaces
some of the files that you are in the process or using, maybe?

Paul T.

Tim Raml said:
what cab file did you use to test it?

Paul G. Tobey said:
Sounds like a possibility. I've also just written a test case in C++ and
it
finishes fine for me.

Paul T.

I've seen this problem before. What worked for me is using
ShellExecuteEx
instead of CreateProcess. You need to set flag SEE_MASK_NOCLOSEPROCESS
in
order to get a valid hProcess to wait for.

If you want to see C++ code, send me an email. Sorry, I don't have
anything C# handy but it should be trivial

--
Alex Feinman
---
Visit http://www.opennetcf.org
apologies in advance...
1) v1.0.5000 to be more precise
2) iPaq h1940 -Microsoft Pocket PC v4.20.0 (Build 14053)
3) hx2110 - Windows Mobile 2003 Second Edition v4.21.1088 (Build
14132)
4) i dont know c, im using c#
5) i pasted code and provided the names of 2 cabs built and provided
by
ms
that demonstarte it not working. the pasted code works for cabs that
i
build
using the tools that were provided by ms.
6) if this is in fact a problem, the chances of it getting fixed in a
timeframe relevant to my schedule is zero...

/me wanders off and tries to implement it in evb, its gotta work in
that...

:

Ah, there's no v1.1 Compact Framework, so that can't be the right
information.

We need to know the version of Pocket PC that you're running into
this
with.
Pocket PC 2000, 2002, 2003, and/or 2003 Second Edition, so we know
what
version of Windows CE they're based on. The chances of getting a
fix,
if
it's only the 2000 or 2002 editions, are pretty low, so I'd
concentrate
on
2003 and 2003SE, if possible.

It would also be a very good idea to try duplicating it in native
code
with
C. Just generate a simple Windows application (not Hello, World),
with
the
new project wizard in eVC. In WinMain(), call CreateProcess() and
WaitForSingleObject() (and, of course, CloseHandle() on the process
handle
after you're done waiting on it).

Report back and post the C code that you use, if it happens with
native
code, too, and I'll try it on a couple of devices that I have here.

Paul T.

Thanks for responding. I am using C# in VS2003 w/ the v1.1
framework.
I've
probably got 10 different PPCs I could test on but this problem is
presently
exhibiting itself on the 2 I am currently using: iPax h1940 and the
hx2110.
I can only assume the others I have will have the same problem.

What else do you want to know?

:

We need details on the device that you're using. If it's doing
what
you
think it's doing, it's a very serious bug in the OS. I think
that's
unlikely, but we'd need to know where to look first...

Paul T.

ok, did that and not real surprised by the result. when i start
the
process,
wceload has 2 threads w/ different ids and the same pid. when
the
process
hangs, i still have 2 threads but the pids are now different so
i
expect
my
Wait is now waiting for the wrong pid. this behavior is only
exhibited
when
im running the MS cabs, not when i run my own.

how do i proceed knowing that?

:

Look at the unit with the Remote Process Viewer and see *if*
the
process
is
exiting. I've never seen a process exit and *not* had the
handle
signaled.

Paul T.

ok, ive read/implemented and read/implemented and
read/implemented...
started w/ the opennetcf implementation and it didnt work and
people
posted
that it didnt work and i saw no soln that did work. i then
implemented
the
apis and had the same result.

everything works great as long as you dont use MS cab files;
the
infinite
wait works fine for cabs ive created for our applications but
does
not
work
w/ either of the following MS cabs:
sqlce.wce4.armv4.CAB
netcf.all.wce4.ARMV4.cab

if i specify a wait time (not w/ the code below) it works but
that
doesnt
do
me any good...

is there something about the MS cabs that make this just not
work or
what?
has anyone found a workaround for this or am i just missing
something?
please help!

code:
public class ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 ProcessId;
public Int32 ThreadId;
}
public class runFile
{
[DllImport("CoreDll.DLL", SetLastError=true)]
private extern static
int CreateProcess( String imageName,
String cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
Int32 boolInheritHandles,
Int32 dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
byte [] si,
ProcessInfo pi );

[DllImport("CoreDll.dll")]
private extern static
Int32 GetLastError();

[DllImport("CoreDll.dll")]
private extern static
Int32 WaitForSingleObject( IntPtr Handle,
Int32 Wait);

public static bool CreateProcess(string ExeName,string
CmdLine,
ProcessInfo pi) //, bool waitForever)
{
Int32 INFINITE;
unchecked {INFINITE = (int)0xFFFFFFFF;}

if ( pi == null )
pi = new ProcessInfo();
byte [] si = new byte[128];
CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero,
0, 0, IntPtr.Zero, IntPtr.Zero, si, pi);
WaitForSingleObject(pi.hProcess,INFINITE);
return true;
}
}


code trying to use above w/ MS cab:
private void button2_Click(object sender, System.EventArgs e)
{
ProcessInfo pi=new ProcessInfo();
string exe;
string arg;
exe="\\windows\\wceload.exe";
//*MUST* use /delete 0, not /nodelete
arg="/delete 0 \"\\program
files\\installer\\sqlce.wce4.armv4.CAB\"";

if (runFile.CreateProcess(exe,arg,pi)) //,true))
}
 
G

Guest

i ran the test app on the ppc2003 1940 and it worked fine using the sql cab.
the app file menu didnt show up on the newer model so i couldnt test it on
there.

that test app is using createprocess to run the file wceload.exe w/ the cab
file as a paramter and waitforsingleobject w/ the id returned from
createprocess and an infinite wait?

not really sure where that leaves me....

Paul G. Tobey said:
Here's the Windows CE 4.2-targeted ARMV4 DEBUG executable. Note that this
is *not* a PPC application (don't have a PPC). I think that it will run on
your device, but I'm not sure about it.

To run it, obviously, start the EXE. From the File menu, choose the Run...
item. This pops up a dialog that gives you a chance to A) exit or B) enter
a path/filename and run the test. When you enter a path and filename and
click Run, the status field shows that the process is running. When the
wceload.exe process indicates that it's done, the status field will be
updated to show that. If you need to terminate the dialog/launcher
application early, just hit OK.

Paul T.

Tim Raml said:
yes, i realize im trying to install the cf while im running a cf app but
for
that i wasnt going to wait for the proc to finish, i was just going to
terminate my app (which may have consequences of its own, havent gotten
that
far).

thats not an issue w/ sqlce.wce4.armv4.CAB, its not even installed on the
device and it hangs at the end just as the cf install does when using
createprocess/wait...

if you have a compiled app i can run on my ppc to test, email it, id love
to
test it here and provide you the results.

Paul G. Tobey said:
Both of the ones that you referenced in your first post, actually (I
wrote
version that pops up a dialog and asks what you want to try).

I think that we have an "interesting situation" in the .NET CF run-time,
rather than, strictly, a bug. You're trying to install a cab that
replaces
some of the files that you are in the process or using, maybe?

Paul T.

what cab file did you use to test it?

:

Sounds like a possibility. I've also just written a test case in C++
and
it
finishes fine for me.

Paul T.

I've seen this problem before. What worked for me is using
ShellExecuteEx
instead of CreateProcess. You need to set flag
SEE_MASK_NOCLOSEPROCESS
in
order to get a valid hProcess to wait for.

If you want to see C++ code, send me an email. Sorry, I don't have
anything C# handy but it should be trivial

--
Alex Feinman
---
Visit http://www.opennetcf.org
apologies in advance...
1) v1.0.5000 to be more precise
2) iPaq h1940 -Microsoft Pocket PC v4.20.0 (Build 14053)
3) hx2110 - Windows Mobile 2003 Second Edition v4.21.1088 (Build
14132)
4) i dont know c, im using c#
5) i pasted code and provided the names of 2 cabs built and
provided
by
ms
that demonstarte it not working. the pasted code works for cabs
that
i
build
using the tools that were provided by ms.
6) if this is in fact a problem, the chances of it getting fixed in
a
timeframe relevant to my schedule is zero...

/me wanders off and tries to implement it in evb, its gotta work in
that...

:

Ah, there's no v1.1 Compact Framework, so that can't be the right
information.

We need to know the version of Pocket PC that you're running into
this
with.
Pocket PC 2000, 2002, 2003, and/or 2003 Second Edition, so we know
what
version of Windows CE they're based on. The chances of getting a
fix,
if
it's only the 2000 or 2002 editions, are pretty low, so I'd
concentrate
on
2003 and 2003SE, if possible.

It would also be a very good idea to try duplicating it in native
code
with
C. Just generate a simple Windows application (not Hello, World),
with
the
new project wizard in eVC. In WinMain(), call CreateProcess() and
WaitForSingleObject() (and, of course, CloseHandle() on the
process
handle
after you're done waiting on it).

Report back and post the C code that you use, if it happens with
native
code, too, and I'll try it on a couple of devices that I have
here.

Paul T.

Thanks for responding. I am using C# in VS2003 w/ the v1.1
framework.
I've
probably got 10 different PPCs I could test on but this problem
is
presently
exhibiting itself on the 2 I am currently using: iPax h1940 and
the
hx2110.
I can only assume the others I have will have the same problem.

What else do you want to know?

:

We need details on the device that you're using. If it's doing
what
you
think it's doing, it's a very serious bug in the OS. I think
that's
unlikely, but we'd need to know where to look first...

Paul T.

ok, did that and not real surprised by the result. when i
start
the
process,
wceload has 2 threads w/ different ids and the same pid.
when
the
process
hangs, i still have 2 threads but the pids are now different
so
i
expect
my
Wait is now waiting for the wrong pid. this behavior is only
exhibited
when
im running the MS cabs, not when i run my own.

how do i proceed knowing that?

:

Look at the unit with the Remote Process Viewer and see *if*
the
process
is
exiting. I've never seen a process exit and *not* had the
handle
signaled.

Paul T.

message
ok, ive read/implemented and read/implemented and
read/implemented...
started w/ the opennetcf implementation and it didnt work
and
people
posted
that it didnt work and i saw no soln that did work. i
then
implemented
the
apis and had the same result.

everything works great as long as you dont use MS cab
files;
the
infinite
wait works fine for cabs ive created for our applications
but
does
not
work
w/ either of the following MS cabs:
sqlce.wce4.armv4.CAB
netcf.all.wce4.ARMV4.cab

if i specify a wait time (not w/ the code below) it works
but
that
doesnt
do
me any good...

is there something about the MS cabs that make this just
not
work or
what?
has anyone found a workaround for this or am i just
missing
something?
please help!

code:
public class ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 ProcessId;
public Int32 ThreadId;
}
public class runFile
{
[DllImport("CoreDll.DLL", SetLastError=true)]
private extern static
int CreateProcess( String imageName,
String cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
Int32 boolInheritHandles,
Int32 dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
byte [] si,
ProcessInfo pi );

[DllImport("CoreDll.dll")]
private extern static
Int32 GetLastError();

[DllImport("CoreDll.dll")]
private extern static
Int32 WaitForSingleObject( IntPtr Handle,
Int32 Wait);

public static bool CreateProcess(string ExeName,string
CmdLine,
ProcessInfo pi) //, bool waitForever)
{
Int32 INFINITE;
unchecked {INFINITE = (int)0xFFFFFFFF;}

if ( pi == null )
pi = new ProcessInfo();
byte [] si = new byte[128];
CreateProcess(ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero,
0, 0, IntPtr.Zero, IntPtr.Zero, si, pi);
WaitForSingleObject(pi.hProcess,INFINITE);
return true;
}
}


code trying to use above w/ MS cab:
private void button2_Click(object sender, System.EventArgs
e)
{
ProcessInfo pi=new ProcessInfo();
string exe;
string arg;
exe="\\windows\\wceload.exe";
//*MUST* use /delete 0, not /nodelete
arg="/delete 0 \"\\program
files\\installer\\sqlce.wce4.armv4.CAB\"";
 
A

Alex Feinman [MVP]

What happens if from your CF app you launch the test app and tell it to
install sqlce cab? I suspect one of them will hang, but which one?

--
Alex Feinman
---
Visit http://www.opennetcf.org
Tim Raml said:
i ran the test app on the ppc2003 1940 and it worked fine using the sql
cab.
the app file menu didnt show up on the newer model so i couldnt test it on
there.

that test app is using createprocess to run the file wceload.exe w/ the
cab
file as a paramter and waitforsingleobject w/ the id returned from
createprocess and an infinite wait?

not really sure where that leaves me....

Paul G. Tobey said:
Here's the Windows CE 4.2-targeted ARMV4 DEBUG executable. Note that
this
is *not* a PPC application (don't have a PPC). I think that it will run
on
your device, but I'm not sure about it.

To run it, obviously, start the EXE. From the File menu, choose the
Run...
item. This pops up a dialog that gives you a chance to A) exit or B)
enter
a path/filename and run the test. When you enter a path and filename and
click Run, the status field shows that the process is running. When the
wceload.exe process indicates that it's done, the status field will be
updated to show that. If you need to terminate the dialog/launcher
application early, just hit OK.

Paul T.

Tim Raml said:
yes, i realize im trying to install the cf while im running a cf app
but
for
that i wasnt going to wait for the proc to finish, i was just going to
terminate my app (which may have consequences of its own, havent gotten
that
far).

thats not an issue w/ sqlce.wce4.armv4.CAB, its not even installed on
the
device and it hangs at the end just as the cf install does when using
createprocess/wait...

if you have a compiled app i can run on my ppc to test, email it, id
love
to
test it here and provide you the results.

:

Both of the ones that you referenced in your first post, actually (I
wrote
version that pops up a dialog and asks what you want to try).

I think that we have an "interesting situation" in the .NET CF
run-time,
rather than, strictly, a bug. You're trying to install a cab that
replaces
some of the files that you are in the process or using, maybe?

Paul T.

what cab file did you use to test it?

:

Sounds like a possibility. I've also just written a test case in
C++
and
it
finishes fine for me.

Paul T.

I've seen this problem before. What worked for me is using
ShellExecuteEx
instead of CreateProcess. You need to set flag
SEE_MASK_NOCLOSEPROCESS
in
order to get a valid hProcess to wait for.

If you want to see C++ code, send me an email. Sorry, I don't
have
anything C# handy but it should be trivial

--
Alex Feinman
---
Visit http://www.opennetcf.org
apologies in advance...
1) v1.0.5000 to be more precise
2) iPaq h1940 -Microsoft Pocket PC v4.20.0 (Build 14053)
3) hx2110 - Windows Mobile 2003 Second Edition v4.21.1088 (Build
14132)
4) i dont know c, im using c#
5) i pasted code and provided the names of 2 cabs built and
provided
by
ms
that demonstarte it not working. the pasted code works for cabs
that
i
build
using the tools that were provided by ms.
6) if this is in fact a problem, the chances of it getting fixed
in
a
timeframe relevant to my schedule is zero...

/me wanders off and tries to implement it in evb, its gotta work
in
that...

:

Ah, there's no v1.1 Compact Framework, so that can't be the
right
information.

We need to know the version of Pocket PC that you're running
into
this
with.
Pocket PC 2000, 2002, 2003, and/or 2003 Second Edition, so we
know
what
version of Windows CE they're based on. The chances of getting
a
fix,
if
it's only the 2000 or 2002 editions, are pretty low, so I'd
concentrate
on
2003 and 2003SE, if possible.

It would also be a very good idea to try duplicating it in
native
code
with
C. Just generate a simple Windows application (not Hello,
World),
with
the
new project wizard in eVC. In WinMain(), call CreateProcess()
and
WaitForSingleObject() (and, of course, CloseHandle() on the
process
handle
after you're done waiting on it).

Report back and post the C code that you use, if it happens
with
native
code, too, and I'll try it on a couple of devices that I have
here.

Paul T.

Thanks for responding. I am using C# in VS2003 w/ the v1.1
framework.
I've
probably got 10 different PPCs I could test on but this
problem
is
presently
exhibiting itself on the 2 I am currently using: iPax h1940
and
the
hx2110.
I can only assume the others I have will have the same
problem.

What else do you want to know?

:

We need details on the device that you're using. If it's
doing
what
you
think it's doing, it's a very serious bug in the OS. I
think
that's
unlikely, but we'd need to know where to look first...

Paul T.

message
ok, did that and not real surprised by the result. when i
start
the
process,
wceload has 2 threads w/ different ids and the same pid.
when
the
process
hangs, i still have 2 threads but the pids are now
different
so
i
expect
my
Wait is now waiting for the wrong pid. this behavior is
only
exhibited
when
im running the MS cabs, not when i run my own.

how do i proceed knowing that?

:

Look at the unit with the Remote Process Viewer and see
*if*
the
process
is
exiting. I've never seen a process exit and *not* had
the
handle
signaled.

Paul T.

message
ok, ive read/implemented and read/implemented and
read/implemented...
started w/ the opennetcf implementation and it didnt
work
and
people
posted
that it didnt work and i saw no soln that did work. i
then
implemented
the
apis and had the same result.

everything works great as long as you dont use MS cab
files;
the
infinite
wait works fine for cabs ive created for our
applications
but
does
not
work
w/ either of the following MS cabs:
sqlce.wce4.armv4.CAB
netcf.all.wce4.ARMV4.cab

if i specify a wait time (not w/ the code below) it
works
but
that
doesnt
do
me any good...

is there something about the MS cabs that make this
just
not
work or
what?
has anyone found a workaround for this or am i just
missing
something?
please help!

code:
public class ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 ProcessId;
public Int32 ThreadId;
}
public class runFile
{
[DllImport("CoreDll.DLL", SetLastError=true)]
private extern static
int CreateProcess( String imageName,
String cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
Int32 boolInheritHandles,
Int32 dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
byte [] si,
ProcessInfo pi );

[DllImport("CoreDll.dll")]
private extern static
Int32 GetLastError();

[DllImport("CoreDll.dll")]
private extern static
Int32 WaitForSingleObject( IntPtr Handle,
Int32 Wait);

public static bool CreateProcess(string ExeName,string
CmdLine,
ProcessInfo pi) //, bool waitForever)
{
Int32 INFINITE;
unchecked {INFINITE = (int)0xFFFFFFFF;}

if ( pi == null )
pi = new ProcessInfo();
byte [] si = new byte[128];
CreateProcess(ExeName, CmdLine, IntPtr.Zero,
IntPtr.Zero,
0, 0, IntPtr.Zero, IntPtr.Zero, si, pi);
WaitForSingleObject(pi.hProcess,INFINITE);
return true;
}
}


code trying to use above w/ MS cab:
private void button2_Click(object sender,
System.EventArgs
e)
{
ProcessInfo pi=new ProcessInfo();
string exe;
string arg;
exe="\\windows\\wceload.exe";
//*MUST* use /delete 0, not /nodelete
arg="/delete 0 \"\\program
files\\installer\\sqlce.wce4.armv4.CAB\"";
 
G

Guest

alex,
i was a bit surprised but if i launch pauls test app from my cf app, and
then install the sqlce cab from pauls app, it hangs...

ive tested the both the create/shell along w/ wait on .vb files using
pvbload, our own cab files, several standalone exes and they never hang on
the wait....

hopefully this helps somehow.
 
G

Guest

correction, using pvbload.exe along w/ .vb files also causes the cf app to
hang at the wait. processviewer shows 3 unique thread ids w/ identical pids.
 
P

Paul G. Tobey [eMVP]

You can enter whatever CAB name you want. It's not checking for you and
showing just those which exist; you have to enter what you want to use.

Yes, it uses CreateProcess() to start the application, using the command
line you indicated in your initial post., substituting the quoted path and
name of the file, as entered in the dialog. As soon as the launch is
complete, it creates a new thread to monitor progress of the install. That
thread does a WaitForMultipleObjects(..., INFINITE). It's waiting on an
event that is fired to signal that you've aborted the wait, as well as the
process handle returned by CreateProcess(). When the wait returns, a
WM_COMMAND message is posted back to the dialog to indicate that the wait is
over. In this way, the dialog is still functional while we wait for the
other process to finish.

I'm pretty confident that this is *not* an OS bug. It may simply be that,
when you're trying to install that CAB file, either the installer or the OS
detects that you're installing a .NET assemblies and that you've already got
a .NET CF program running which is using them. I don't know exactly what it
might be doing, then, to cause this problem (although I can think of lots of
far-fetched explanations).

Paul T.

Tim Raml said:
i ran the test app on the ppc2003 1940 and it worked fine using the sql
cab.
the app file menu didnt show up on the newer model so i couldnt test it on
there.

that test app is using createprocess to run the file wceload.exe w/ the
cab
file as a paramter and waitforsingleobject w/ the id returned from
createprocess and an infinite wait?

not really sure where that leaves me....

Paul G. Tobey said:
Here's the Windows CE 4.2-targeted ARMV4 DEBUG executable. Note that
this
is *not* a PPC application (don't have a PPC). I think that it will run
on
your device, but I'm not sure about it.

To run it, obviously, start the EXE. From the File menu, choose the
Run...
item. This pops up a dialog that gives you a chance to A) exit or B)
enter
a path/filename and run the test. When you enter a path and filename and
click Run, the status field shows that the process is running. When the
wceload.exe process indicates that it's done, the status field will be
updated to show that. If you need to terminate the dialog/launcher
application early, just hit OK.

Paul T.

Tim Raml said:
yes, i realize im trying to install the cf while im running a cf app
but
for
that i wasnt going to wait for the proc to finish, i was just going to
terminate my app (which may have consequences of its own, havent gotten
that
far).

thats not an issue w/ sqlce.wce4.armv4.CAB, its not even installed on
the
device and it hangs at the end just as the cf install does when using
createprocess/wait...

if you have a compiled app i can run on my ppc to test, email it, id
love
to
test it here and provide you the results.

:

Both of the ones that you referenced in your first post, actually (I
wrote
version that pops up a dialog and asks what you want to try).

I think that we have an "interesting situation" in the .NET CF
run-time,
rather than, strictly, a bug. You're trying to install a cab that
replaces
some of the files that you are in the process or using, maybe?

Paul T.

what cab file did you use to test it?

:

Sounds like a possibility. I've also just written a test case in
C++
and
it
finishes fine for me.

Paul T.

I've seen this problem before. What worked for me is using
ShellExecuteEx
instead of CreateProcess. You need to set flag
SEE_MASK_NOCLOSEPROCESS
in
order to get a valid hProcess to wait for.

If you want to see C++ code, send me an email. Sorry, I don't
have
anything C# handy but it should be trivial

--
Alex Feinman
---
Visit http://www.opennetcf.org
apologies in advance...
1) v1.0.5000 to be more precise
2) iPaq h1940 -Microsoft Pocket PC v4.20.0 (Build 14053)
3) hx2110 - Windows Mobile 2003 Second Edition v4.21.1088 (Build
14132)
4) i dont know c, im using c#
5) i pasted code and provided the names of 2 cabs built and
provided
by
ms
that demonstarte it not working. the pasted code works for cabs
that
i
build
using the tools that were provided by ms.
6) if this is in fact a problem, the chances of it getting fixed
in
a
timeframe relevant to my schedule is zero...

/me wanders off and tries to implement it in evb, its gotta work
in
that...

:

Ah, there's no v1.1 Compact Framework, so that can't be the
right
information.

We need to know the version of Pocket PC that you're running
into
this
with.
Pocket PC 2000, 2002, 2003, and/or 2003 Second Edition, so we
know
what
version of Windows CE they're based on. The chances of getting
a
fix,
if
it's only the 2000 or 2002 editions, are pretty low, so I'd
concentrate
on
2003 and 2003SE, if possible.

It would also be a very good idea to try duplicating it in
native
code
with
C. Just generate a simple Windows application (not Hello,
World),
with
the
new project wizard in eVC. In WinMain(), call CreateProcess()
and
WaitForSingleObject() (and, of course, CloseHandle() on the
process
handle
after you're done waiting on it).

Report back and post the C code that you use, if it happens
with
native
code, too, and I'll try it on a couple of devices that I have
here.

Paul T.

Thanks for responding. I am using C# in VS2003 w/ the v1.1
framework.
I've
probably got 10 different PPCs I could test on but this
problem
is
presently
exhibiting itself on the 2 I am currently using: iPax h1940
and
the
hx2110.
I can only assume the others I have will have the same
problem.

What else do you want to know?

:

We need details on the device that you're using. If it's
doing
what
you
think it's doing, it's a very serious bug in the OS. I
think
that's
unlikely, but we'd need to know where to look first...

Paul T.

message
ok, did that and not real surprised by the result. when i
start
the
process,
wceload has 2 threads w/ different ids and the same pid.
when
the
process
hangs, i still have 2 threads but the pids are now
different
so
i
expect
my
Wait is now waiting for the wrong pid. this behavior is
only
exhibited
when
im running the MS cabs, not when i run my own.

how do i proceed knowing that?

:

Look at the unit with the Remote Process Viewer and see
*if*
the
process
is
exiting. I've never seen a process exit and *not* had
the
handle
signaled.

Paul T.

message
ok, ive read/implemented and read/implemented and
read/implemented...
started w/ the opennetcf implementation and it didnt
work
and
people
posted
that it didnt work and i saw no soln that did work. i
then
implemented
the
apis and had the same result.

everything works great as long as you dont use MS cab
files;
the
infinite
wait works fine for cabs ive created for our
applications
but
does
not
work
w/ either of the following MS cabs:
sqlce.wce4.armv4.CAB
netcf.all.wce4.ARMV4.cab

if i specify a wait time (not w/ the code below) it
works
but
that
doesnt
do
me any good...

is there something about the MS cabs that make this
just
not
work or
what?
has anyone found a workaround for this or am i just
missing
something?
please help!

code:
public class ProcessInfo
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 ProcessId;
public Int32 ThreadId;
}
public class runFile
{
[DllImport("CoreDll.DLL", SetLastError=true)]
private extern static
int CreateProcess( String imageName,
String cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
Int32 boolInheritHandles,
Int32 dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
byte [] si,
ProcessInfo pi );

[DllImport("CoreDll.dll")]
private extern static
Int32 GetLastError();

[DllImport("CoreDll.dll")]
private extern static
Int32 WaitForSingleObject( IntPtr Handle,
Int32 Wait);

public static bool CreateProcess(string ExeName,string
CmdLine,
ProcessInfo pi) //, bool waitForever)
{
Int32 INFINITE;
unchecked {INFINITE = (int)0xFFFFFFFF;}

if ( pi == null )
pi = new ProcessInfo();
byte [] si = new byte[128];
CreateProcess(ExeName, CmdLine, IntPtr.Zero,
IntPtr.Zero,
0, 0, IntPtr.Zero, IntPtr.Zero, si, pi);
WaitForSingleObject(pi.hProcess,INFINITE);
return true;
}
}


code trying to use above w/ MS cab:
private void button2_Click(object sender,
System.EventArgs
e)
{
ProcessInfo pi=new ProcessInfo();
string exe;
string arg;
exe="\\windows\\wceload.exe";
//*MUST* use /delete 0, not /nodelete
arg="/delete 0 \"\\program
files\\installer\\sqlce.wce4.armv4.CAB\"";
 
G

Guest

i might buy that but since the hanging behavior is the same when using
pvbload in combination w/ a .vb, i suspect there is something wrong
somewhere...

id like to think that using pvbload in combination w/ a .vb has absolutely
no interaction w/ anything .net related. if it does, thatd imply installing
the framework has some affect on either .vb files, pvbload, or both....
 

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