1

I built an application in c# vs2005 .net .

Everything works fine when i run the application in win 32 bit, But when running the application in win 64 it crashes while trying to call the pinvoke interlockedexchange(which is within the kernel32.dll) function .

This is the exception : unable to find an entry point named 'interlockedexchange'

I didnt find the interlockedexchange function within the kernel32.dll under system32 directory but it was found under the syswow64 directory(in the kernel32.dll) .

I guess that the .net runtime is configured to the system32 directory and not to the syswow64 . How is it possible to change this configuration ? Can you think of any other problem that could cause this? any help would be appreciated! thanks ,

Miki Amit

Miki Amit
  • 13
  • 3

2 Answers2

0

This does not directly answer your question, but why not call System.Threading.Interlocked.Exhange() rather than resorting to P/Invoke?

Paul Ruane
  • 37,459
  • 12
  • 63
  • 82
  • Thanks for your reply! I need to set a Shared Memory Intptr (pointer) and far as i know the Interlocked.Exhange can change only .net variables – Miki Amit Apr 08 '10 at 11:41
  • 1
    @Miki, this is not the case, the .NET Interlocked.Exchange can operate on any memory location whatsoever. If it's .NET memory, you have to pin it first, of course. See http://stackoverflow.com/questions/1116790/c-sharp-interlocked-exchange/5589515#5589515. – Glenn Slayden Jul 29 '12 at 18:58
0

If you are set on using InterlockedExchange and want the 32-bit version, you can change your project settings to force it to run as 32-bit. Go to the "Build" tab in the project settings and change "Platform target" to x86. It will then run as 32-bit.

Mark Wilkins
  • 40,729
  • 5
  • 57
  • 110