Category: Win32

22 Nov

Porting .NET app to Vista.. DEP strikes!


An interesting issue happened these days when I tried to port some apps to Vista.

Basically all .NET apps compiled with Visual Studio 2005/2008 are marked “NX compatible” by default. If your .NET app uses an incompatible DLL or COM object, the app will crash. What I found funny was that the message was a standard access violation error instead of a more specific DEP error.

Debugging it was not easy: I was unable to step through the code in VS2005 and using WinDbg wasn’t much of help too, except that the line where it crashed was something like a mov [esp+24h], constant with ESP well within limits — an instruction which should not generate an access violation exception given the current ESP value.  At that point I was starting to think that my “attempt to read or write protected memory was, in fact, something else.

Luckily my mind went to DEP and in less than 1 minute of Google search I was able to find this link with a good solution which, for the lazy and to preserve history is to add the following two lines as a post-build step.

call “$(DevEnvDir)..\tools\vsvars32.bat”
editbin.exe /NXCOMPAT:NO $(TargetPath)

I tried, without much faith, and it worked. And the C# app was finally working on Vista. And while you are fuddling with post-builds, go on and enable LARGEADDRESSAWARE while you are at it. 32bit users will thank you.

20 Mar

Vista and Visual Studio Remote Debugger

If you want to run Remote Debugger under Windows Vista you might encounter problems with the firewall.

Check this :

Also, you can run Remote debugger without installing Visual Studio 2005, just by copying the files.

Filed under: C++, Programming, Win32