Reputation: 3126
P/Invoke on x64 null reference exceptions
I get null reference exceptions when I try to compile for x64 in .NET code that makes use of platform invocation services to call unmanaged code in dlls. Am I missing something obvious here?
e.g. call to
Private Declare Function waveOutOpen Lib "winmm.dll" (ByRef lphWaveOut As Int32, ByVal uDeviceID As Int32, ByRef lpFormat As WAVEFORMATEX, ByVal dwCallback As WaveDelegate, ByVal dwInstance As Int32, ByVal dwFlags As Int32) As Int32
fails in:
full code here: waveout sometimes memory issue
Upvotes: 0
Views: 464
Reputation: 60276
Are you maybe using a bunch of int
(fixed-size 32 bits) where in fact an IntPtr
(size varies depending on platform) would be required?
Upvotes: 2
Reputation: 43645
There is not 64 bit version of that unmanaged dll. The 32 bits version gets called and of course things don't really align?
Upvotes: 0