0

I have a serious problem with my .Net program. It calls a native dll, and then crashes instantly because it can't find a native method. This is behaviour we have seen before, whereby the C# compiler, in its infinite wisdom, sets the flag that the program is DEP compatible, even if it calls a native dll which patently is not.

We have the standard workaround for this, where the flag is set to Not DEP Compatible in a post-build step, and this works fine. Everywhere except on my machine. I have Windows 7 32bit, and the program works fine on the Win 7 64bit machines that we have, as well as on Vista and XP.

However, on my machine the DataExecutionPolicy_SupportPolicy is 0, i.e. we have successfully switched DEP off. Does anyone know whether there is some situation in which it can still act? Or any other mechanism which could have the same effect?

We have now also checked on another newly installed Win7 32bit machine (also a Thinkpad like mine), and it also works there. We have compared all the bios settings, and they are similar (mine is a T61, the other an R60).

The dll in question also works fine on my machine when called from a native program. We are running out of ideas... any help would be much appreciated!

Joel in Gö
  • 7,460
  • 9
  • 47
  • 77
  • `, whereby the C# compiler, in its infinite wisdom, sets the flag that the program is DEP compatible, even if it calls a native dll which patently is not.` Anyway to override the said flag some other way? (I'm coming from zero experience here.) – Moshe Apr 08 '10 at 20:35
  • Not as far as I know; see http://stackoverflow.com/questions/350977/how-to-make-my-program-dep-compatible/351087#351087 for how to do it after compilation. – Joel in Gö Apr 09 '10 at 07:27
  • If you're running into problems from DEP, your native dll is broken. Leaving DEP off is a compatibility measure. – Yuliy Apr 12 '10 at 08:28
  • ...not broken, lost. See my accepted answer. – Joel in Gö Apr 12 '10 at 08:38

1 Answers1

0

OK, the problem was after all something completely different. My machine was the only one where the path for the native dlls was not set correctly; this led to an instant crash in Win7, while in XP there used to be a message box giving a (highly cryptic) idea of what had happened.

So we can absolve DEP of any blame. I am leaving it in the title so that other people who have the same suspicion remember to check their file paths!

Joel in Gö
  • 7,460
  • 9
  • 47
  • 77