The information in this article applies to:
SUMMARYFor the same piece of code, a Visual Basic application's behavior can be different when running as a compiled EXE and when running in debug mode in the IDE. This article explains the most common reasons why an application's behavior can be different and recommend ways to handle these situations. MORE INFORMATIONFocus issuesThis is the most common reason for differences in behavior. While running in Debug mode, the focus change exists between the forms and Visual Basic IDE, and such foucs changes are not possible while running as an EXE. In addition, using message boxes in focus intensive applications will cause huge differences in behavior between compiled and debug modes.Recommendations:
Interpreter Vs Compiler issuesWhen running in Debug mode, the code is interpreted, while in run mode, the code is compiled and executed. The behavior difference may be because of the difference in the way the Interpreter and Compiler handle some code.Recommendations:
Issues with yielding to other processesWhen running in Debug mode and stepping each line of code, the processor gets enough time to yield to other processes and it is somewhat similar to calling DoEvents each time you enter into Debug mode. A compiled application may not yield to the processor at the expected line of code.Recommendations:
ThreadingThe IDE has only two threads running at a time. A background thread allows Visual Basic to process the Control-Break while running code that is not yeilding time. To be able to access DataMembers and allow for compile on demand Visual Basic restricts all components running in Debug mode to a single thread of execution. This is especially important when debugging ActiveX components. For example, adding an ActiveX DLL project to a Standard EXE project for debugging may not work the same as when you debug the EXE using the compiled DLL. This also effects any programs that depend on name space seperation to function properly. For example, if you reference a variable defined in a standard bas module, this variable will be shared across every module running on the same thread. So in the IDE, if you change this variable in one class other classes will also see the change. This can lead to the mistaken impression that variables in base modules are global when they are really only thread global. When your application runs in compiled mode the variable may no longer be shared. To learn more about how data is shared in a multithreaded environment, please look for the topic "Apartment-Model Threading in Visual Basic" in MSDN Help or Books Online.Recommendations:
Other Causes:Usually, the issues with differences in bahavior can be resolved by following the recommandations given earlier. You may experience differences due to other reasons also. Contact developer support at this stage.REFERENCESFor additional information, please click the article numbers below to view the articles in the Microsoft Knowledge Base: Q166275 HOWTO: Debug a Native Code Visual Basic Component in VC++ Q193133 HOWTO: Compile VB Programs with Debug Symbols Embedded Q161153 HOWTO: Use the Assert Method for Debugging Q192549 INFO: VBCE: Overview of Debugging VBCE Applications Q138521 INFO: Program Compiles in Background w/Compile On Demand Set Additional query words: automation error F8 F5 interface development running outcome path
Keywords : kbCompiler kbDebug kbThread kbVBp kbVBp400 kbVBp500 kbVBp600 kbIDEProject kbGrpVB kbDSupport |
Last Reviewed: September 13, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |