Click here to Skip to main content
15,920,632 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: upgrade Pin
Dan Neely24-Oct-06 2:13
Dan Neely24-Oct-06 2:13 
QuestionManaged DirectX 2.0 Beta Removed Pin
wout de zeeuw23-Oct-06 17:14
wout de zeeuw23-Oct-06 17:14 
Questionthread problem Pin
Tauseef A20-Oct-06 23:08
Tauseef A20-Oct-06 23:08 
AnswerRe: thread problem Pin
indianet23-Oct-06 5:24
indianet23-Oct-06 5:24 
Questionhi Com port communication Pin
Tauseef A18-Oct-06 21:06
Tauseef A18-Oct-06 21:06 
Questionhi help me plz Pin
Tauseef A18-Oct-06 21:00
Tauseef A18-Oct-06 21:00 
AnswerRe: hi help me plz Pin
Christian Graus19-Oct-06 5:41
protectorChristian Graus19-Oct-06 5:41 
AnswerRe: hi help me plz Pin
Mike Dimmick19-Oct-06 6:45
Mike Dimmick19-Oct-06 6:45 
Most likely the unmanaged code is __cdecl but the P/Invoke declaration had CallingConvention=CallingConvention.Winapi (which is the default), which maps to CallingConvention.Stdcall on x86.

Windows on x86 has a number of calling conventions which define how parameters are passed to a called function, and whose responsibility it is to clean up. The __cdecl calling convention is the default for C and C++, where the calling function pushes the parameters onto the stack from right to left (last parameter first, so the first parameter is on top of the stack), and the calling function is also responsible for removing them again. This aids in implementation of functions with variable argument lists (similar to params in C#) since the first argument is always in the same place, and the called function doesn't need to know how many arguments were pushed.

The OS uses the __stdcall calling convention on x86, originally to save a little code space. This convention pushes the arguments in the same way as __cdecl, but now the called function is responsible for removing the arguments from the stack.

Because this is such a common mistake, the CLR contains code to detect, after making a P/Invoke call and doing any required adjustments, that the stack pointer is what it was before the function was called. It doesn't correct the problem because there could be other reasons for an unbalanced stack.

The problem goes away on mobile devices and 64-bit operating systems, where there is only one calling convention.

To correct it, you probably need to set CallingConvention=CallingConvention.Cdecl on your [DllImport] attribute. If in VB and using a Declare statement, you'll have to convert to using the DllImport attribute.

Stability. What an interesting concept. -- Chris Maunder

QuestionRe: hi help me plz Pin
Tauseef A19-Oct-06 7:07
Tauseef A19-Oct-06 7:07 
QuestionActivedocument error - word addin problem Pin
K edar V18-Oct-06 20:08
K edar V18-Oct-06 20:08 
AnswerRe: Activedocument error - word addin problem Pin
Dave Sexton18-Oct-06 20:19
Dave Sexton18-Oct-06 20:19 
GeneralRe: Activedocument error - word addin problem Pin
K edar V18-Oct-06 20:22
K edar V18-Oct-06 20:22 
Question.NET WebMethods - Serialization Pin
Simon P Stevens18-Oct-06 5:58
Simon P Stevens18-Oct-06 5:58 
QuestionSQL Server 2000 Notification Services and .NET 2.0 Pin
asasov17-Oct-06 21:01
asasov17-Oct-06 21:01 
AnswerRe: SQL Server 2000 Notification Services and .NET 2.0 Pin
The Man from U.N.C.L.E.19-Oct-06 7:28
The Man from U.N.C.L.E.19-Oct-06 7:28 
GeneralRe: SQL Server 2000 Notification Services and .NET 2.0 Pin
asasov23-Oct-06 1:52
asasov23-Oct-06 1:52 
QuestionProblem in starting Windows Service written in .Net Pin
Renukapadhamanaban17-Oct-06 19:25
Renukapadhamanaban17-Oct-06 19:25 
AnswerRe: Problem in starting Windows Service written in .Net Pin
User 58385217-Oct-06 20:27
User 58385217-Oct-06 20:27 
AnswerRe: Problem in starting Windows Service written in .Net Pin
Mike Dimmick18-Oct-06 0:35
Mike Dimmick18-Oct-06 0:35 
GeneralRe: Problem in starting Windows Service written in .Net Pin
Renukapadhamanaban18-Oct-06 16:01
Renukapadhamanaban18-Oct-06 16:01 
QuestionDDE in .NET Pin
HakunaMatada17-Oct-06 19:22
HakunaMatada17-Oct-06 19:22 
AnswerRe: DDE in .NET Pin
Mike Dimmick18-Oct-06 0:40
Mike Dimmick18-Oct-06 0:40 
QuestionWindows service requires large memory allocation Pin
Luis C17-Oct-06 5:15
Luis C17-Oct-06 5:15 
AnswerRe: Windows service requires large memory allocation Pin
Dave Kreskowiak17-Oct-06 6:07
mveDave Kreskowiak17-Oct-06 6:07 
GeneralRe: Windows service requires large memory allocation Pin
Luis C17-Oct-06 6:46
Luis C17-Oct-06 6:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.