Debugging Native Code MDL Applications


  
 

This Client Server article is republished in its entirety from 2004 for reference purposes.

By Michael Dougherty, Senior Developer Support Analyst, Bentley Corporate Office
09 August 2004

One reason to build native code MDL applications is their ability to utilize Microsoft's tools, such as the visual debugger. However, this ability may not be apparent if you're building the application using Bentley's Make utility and Make files. Setting Microsoft's visual debugger to debug native code MDL applications is a fairly simple process, and this article will provide the steps to accomplish this.

Compiling For Debug

The first step in debugging an MDL application is compiling it for debug. This will put the debugging information into the executable, (or .pdb file) for the .ma, .dll, and exe. To accomplish this using Bentley's development environment you will need to utilize the -ddebug switch.

Example: bmake -a -ddebug myapp

Connecting to MicroStation

Debugging a native-code MDL application (DLL) using Microsoft's Visual Debugger is the same as debugging any other DLL. The first step is to start Microsoft's Visual C++ and beginning the process to attach (in this case start MicroStation). To connect to the MicroStation process, select Build > Start Debug > Attach to Process from Microsoft's Visual C++ menu. You will be presented with a dialog. Select ustation.exe.


An alternative method to connect to the MicroStation process is to connect through the MicroStation development shell. To connect this way, you will need to know the Process ID, which can be obtained from the Windows Task Manager.

 

Once this is obtained, you can start Visual C++ by sending a keyin from the development shell:

msdev -p 

Example: Msdev -p4064

Debugging the Application

Once connected to the MicroStation process, you can add the application to debug. The first step is to include the application's DLL. Select Project > Settings, and select the Debug tab. Change the Category option to Additional DLLs. Select the application's DLL and click OK.

 

Next, open the source code file for the application and set a break point. Note: The best place to set a break point is in the MdlMain function. Next, load your application from within MicroStation. When the break point is reached, your application is ready for debugging.

See Also

Client Server Archive

MicroStation Desktop TechNotes and FAQs

Comments or Corrections?

Bentley's Technical Support Group requests that you please confine any comments you have on this Wiki entry to this "Comments or Corrections?" section. THANK YOU!