Recieve error message "XXXXX..has stopped working" when launching 7.0 SDK app that includes VBA customizations


Symptoms


Consider the following scenario in Microsoft Dynamics SL 7.0 Feature Pack 1 (FP1).  You create an application by using the Software Development Kit (SDK), and then add a VBA customization with code.  When you start the application, you receive the following error message:

"Microsoft Windows

<ApplicationName>. ..has stopped working"

Where <ApplicationName> is the name of the application that you created for Microsoft Dynamics SL 7.0 Feature Pack 1 (FP1).

Cause


An application that uses components built with ATL version 7.1 or earlier is built with the /NXCOMPAT (http://msdn2.microsoft.com/en-us/library/ms235442.aspx) switch, or is otherwise treated by the OS as being "No eXecute Compatible".  Installing Visual Studio 2008 can cause programs subsequently built with VS 2008 or VS 2005 to enable NX compatibility by default.  Also, if the DEP policy for the system is set to AlwaysOn, applications that incorporate the older thunking code (used to translate memory addresses (pointers) between 16-bit and 32-bit code) will see this problem.

 

Resolution


Build the Project with setting in the Post-build events to remove the /NXCOMPAT switch as follows in Visual Studio 2008:

1) Open the SDK 7.0 project with Visual Studio 2008.
2) Right-click and select properties
3) Select the Compile tab
4) Click the "Build Events" button at the bottom
5) Add the following to the "Post-build" events
call "$(DevEnvDir)..\tools\vsvars32.bat"
editbin.exe /NXCOMPAT:NO "$(TargetPath)"

6) Save and build the project

More Information


Refer to http://support.microsoft.com/kb/948468 for more information.