Delen via


MapPoint and Data Execution Prevention(DEP)

A developer using MapPoint 2006 and Visual Studio 2008 on Vista was developing a windows based application, with the MapPoint control placed on the windows form. He was using the following code:

Private _objMap As MapPoint.Map
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      _objMap = AxMappointControl1.NewMap(MapPoint.GeoMapRegion.geoMapEurope)
End Sub

Every time he ran the application he got the following exception

"Error loading MapPoint. Cause unknown"

I researched on the case and found that this is due to the Data Execution Prevention(DEP) feature of the Windows. Newer versions of Windows (e.g., XP SP2, 2003 Server, Vista) provide additional protection against malicious attacks via the DEP feature. For more information on DEP, go to:

https://msdn.microsoft.com/en-us/library/aa366553.aspx

An application that uses components built with ATL version 7.1 or earlier is built with the /NXCOMPAT (https://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. for more information goto:

https://support.microsoft.com/kb/948468

To solve the problem:

1) Open the project in the Visual Studio

2) Go to Project->Properties, Select compile Tab and click "Build Events..." button. Copy the following commands in the "Post-build events command line"    text area:
  
   call "$(DevEnvDir)..\tools\vsvars32.bat" editbin.exe /NXCOMPAT:NO "$(TargetPath)"

3) Save the project, build and run the project.

4) If you still get the same exception from the application then press Ctrl+F5 to see if the application runs without debugging.

5) If it runs successfully then go to project's property page, and then to "Debug" tab. Uncheck the "Enable the Visual Studio hosting process".

6) Press F5 and run the application.

Using the above mentioned steps the developer was able to run his application without any problem.

Comments

  • Anonymous
    October 09, 2008
    The comment has been removed