Hi,
Module written in 1.1 makes call to sleep.
The declaration in the module is:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Moved project to 2.0

Now I get an MDA Error:

PInvokeStackImbalance was detected
Message: A call to PInvoke function 'NameSpace.basGeneral::Sleep' has
unbalanced the stack. This is likely because the managed PInvoke signature
does not match the unmanaged target signature. Check that the calling
convention and parameters of the PInvoke signature match the target
unmanaged signature.


Any suggestions on how to remedy this would be appreciated.

Thanks

Bob

Re: CLR 2.0 Sleep Call. by Mattias

Mattias
Sun Mar 26 15:37:01 CST 2006

>Any suggestions on how to remedy this would be appreciated.

Call System.Threading.Thread.Sleep instead.


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Re: CLR 2.0 Sleep Call. by Tim

Tim
Sun Mar 26 15:43:26 CST 2006

Try changing the Long to an Integer.
http://pinvoke.net/default.aspx/kernel32/Sleep.html

Is there a particular reason why you're not using the Shared Sleep method of
the Thread class?
http://msdn2.microsoft.com/en-us/library/d00bd51t(VS.80).aspx

--
Tim Wilson
.NET Compact Framework MVP

"Bob" <bob@nowhere.com> wrote in message
news:epeSMtRUGHA.4952@TK2MSFTNGP09.phx.gbl...
> Hi,
> Module written in 1.1 makes call to sleep.
> The declaration in the module is:
> Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
>
> Moved project to 2.0
>
> Now I get an MDA Error:
>
> PInvokeStackImbalance was detected
> Message: A call to PInvoke function 'NameSpace.basGeneral::Sleep' has
> unbalanced the stack. This is likely because the managed PInvoke signature
> does not match the unmanaged target signature. Check that the calling
> convention and parameters of the PInvoke signature match the target
> unmanaged signature.
>
>
> Any suggestions on how to remedy this would be appreciated.
>
> Thanks
>
> Bob
>
>



Re: CLR 2.0 Sleep Call. by Bob

Bob
Sun Mar 26 17:13:34 CST 2006

Thanks Tim,
Right on the money.
Works OK with an Integer in the declaration.
Re: The shared Thread sleep
Spot on.
The external call was historical.
I tried earlier but must have been asleep at the wheel. I made the call
Thread.CurrentThread.Sleep
and just panicked when it spat the dummy.

I'll go through and convert to Thread.Sleep
Thanks again
Bob
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message
news:%23oWOF5RUGHA.5908@TK2MSFTNGP14.phx.gbl...
> Try changing the Long to an Integer.
> http://pinvoke.net/default.aspx/kernel32/Sleep.html
>
> Is there a particular reason why you're not using the Shared Sleep method
of
> the Thread class?
> http://msdn2.microsoft.com/en-us/library/d00bd51t(VS.80).aspx
>
> --
> Tim Wilson
> .NET Compact Framework MVP
>
> "Bob" <bob@nowhere.com> wrote in message
> news:epeSMtRUGHA.4952@TK2MSFTNGP09.phx.gbl...
> > Hi,
> > Module written in 1.1 makes call to sleep.
> > The declaration in the module is:
> > Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
> >
> > Moved project to 2.0
> >
> > Now I get an MDA Error:
> >
> > PInvokeStackImbalance was detected
> > Message: A call to PInvoke function 'NameSpace.basGeneral::Sleep' has
> > unbalanced the stack. This is likely because the managed PInvoke
signature
> > does not match the unmanaged target signature. Check that the calling
> > convention and parameters of the PInvoke signature match the target
> > unmanaged signature.
> >
> >
> > Any suggestions on how to remedy this would be appreciated.
> >
> > Thanks
> >
> > Bob
> >
> >
>
>