Cheat Sheets, Best Practices and Troubleshooting
An exception is thrown or an application crashes.
a. To check what exception is thrown, enable the Common Language Runtime Exceptions option (CTRL+ALT+E) and disable the Enable Just My Code (Managed Only) option as described in the How to obtain the exception's call stack KB article;
b. Once the exception is thrown, investigate the current call stack to see what methods were called. Then analyze stack traces in other threads. For this, click the Debug | Windows | Threads menu item. In the Threads window, click the "Expand callstacks" item in the toolbar.
If the stack contains your own methods, go to the top method and see if your custom code causes the issue. It will be helpful to insert a break point into a “problematic” method (see Use breakpoints in the Visual Studio debugger), navigate through your code lines and check values of variables (see Watch variables with Watch windows and QuickWatch).
If the call stack does not contain neither your methods, nor ours, try searching for a solution on the Internet or posting the issue on any popular .NET forum like StackOverflow.
If the call stack indicates that the issue lies in our code, try searching bug reports in our Support Center to know if a similar issue was fixed in the past or an active bug report exists. You can also upgrade your project to the latest available version to check this point.
An application operates as expected locally but crashes on a client side
a. Usually, such an issue occurs when a deployment package does not contain all the required assemblies. To ensure that you added all the necessary libraries, use our Assembly Deployment Tool;
b. Enable exception logging in code as described in the How to obtain the exception's call stack KB article. Once you obtain a log file, investigate exceptions’ details as described in the following section of this article: An exception is thrown or an application crashes. See the b paragraph.
An option/functionality does not work.
a. Check our documentation regarding the option you are using to ensure that there are no specifics or limitations applied to it. To navigate to a corresponding help topic fast, just click the option name in the VS code editor and press F1 or use our Search Engine (or any another one);
b. Check if any exceptions are thrown as described in the following section of this article: An exception is thrown or an application crashes;
c. If you are using a descendant of our control, try to reproduce the issue by using our regular control instead since there is a chance that the issue relates to your custom implementation;
d. If you handle any events of our controls, comment out their event handlers one by one to check if they do not affect the behavior. Usually, such a technique allows you to narrow down the issue;
e. Use break-points to navigate through your executed code and check at what point it stops operating properly (refer to the following section of this article: An exception is thrown or an application crashes. See the b paragraph).
Data is not shown, or cannot be edited, or data changes are not posted to a data base
a. Check if any exceptions are thrown as described in the following section of this article: An exception is thrown or an application crashes;
b. Determine if the issue relates to our controls or data-access operations. To do this, use a standard data-aware control like DataGridView. Bind it to the same data source and check results. If this control illustrates the same behavior, try searching for a solution on the Internet or posting the issue on any popular .NET forum like StackOverflow;
c. Refer to the following article that describes most common issues related to data operations and data binding: DevExpress WinForms Troubleshooting - Data Binding Issues.
Controls/forms are loaded/operate slowly
a. If the latency issue occurs only on first load, refer to the Why does my code take longer to execute the first time it's run? KB article for more information about this case;
b. Check if any exception is thrown as described in the following section of this article: An exception is thrown or an application crashes;
c. Ensure that your data-access or other custom operations do not take much time on loading/showing a control/form. You can measure how long your operations are executed by using Stopwatch;
d. Check if you do not perform any "heavy" logic on events that are raised frequently. The most common mistake is to execute such code on drawing control elements or accessing cell values (for instance, in the GridView.CustomDrawCell or GridView.CustomUnboundColumnData event handler);
e. Use any performance profiler (the built-in VS one, or dotTrace, or any another one) to measure your application performance and find the bottleneck.
Memory leaks occur or OutOfMemoryException is thrown
OutOfMemoryException can occur in the following cases:
- When no more virtual memory can be allocated for an application (see: OutOfMemoryException class). In this case, a current call stack only indicates the place where memory allocation failed and does not refer to a problematic method. .NET memory profilers, like VS built-in one (which is suitable for simple cases) or dotMemory can be used to investigate memory leaks in your application.
- When the application is running out of object handles. A handle is created by the system for each control, image, font, icon, etc. created by the application, and the number of such handles is limited by the OS (see: Pushing the Limits of Windows: USER and GDI Objects – Part 1). This issue occurs most commonly when controls, fonts, or other components are repeatedly created and not disposed of. The Process Explorer tool can be used to check the number of object handles created by the application:
- On an attempt to perform an invalid operation via GDI+, which is a graphics engine used by the Windows Forms platform. In this case, the exception's call stack will likely contain the API from the System.Drawing namespace. For example, when a read/write operation is performed on an image outside of its bounds, or a disposed graphical object is used.
A red cross is shown
a. Check if any exception is thrown as described in the following section of this article: An exception is thrown or an application crashes;
b. If you are using multi-threading in your project, check if your perform actions in a thread-safe manner. That is, do not change a control's state or its properties in a background thread. Refer to the How to: Make thread-safe calls to Windows Forms controls Microsoft docs to learn how to perform thread-safe operations;
c. Comment out all CustomDraw~ event handlers. If the issue is not reproduced any longer, uncomment event handlers one by one to find a bottleneck. Probably, the issue occurs because your code triggers an extra WM_Paint message and causes re-entering of the Control.OnPaint method. Do not call any thread-blocking methods in such event handlers and do not change control settings there.
d. If you are calling the Application.DoEvents method, comment it out and check if the issue still occurs. This method interrupts the code execution to process all Windows messages currently present in the message queue. The Windows messages may change a control's state and this can lead to unexpected behavior. Refer to the following article for details: Application.DoEvents.
e. Make sure that your application is not running out of memory, handles or GDI objects. Please check the previous Memory leaks occur or OutOfMemoryException is thrown section for details.
An error occurs at design time, or VS freezes
a. Check if any exception is thrown as described in the How to obtain a design-time exception call stack KB article;
b. Temporary disable all VS extensions to ensure that they do not affect the behavior.
c. Refer to the following article that describes most common issues that occur at design-time: DevExpress WinForms Troubleshooting - Visual Studio Designer displays an error or throws an exception.
Custom drawings are not in effect
If you are working in DirectX mode, any drawings executed by GDI+ will be ignored. That is why, it is necessary to use GraphicsCache to draw a custom content. To detect all problematic APIs related to a control appearance with ease, we recommend enabling diagnostics by using the static WindowsFormsSettings.ForcePaintApiDiagnostics method. In addition, make sure that you set the e.Handled parameter to True in a custom draw event handler.
A project does not operate properly or cannot be run after upgrade
a. If control behavior was changed, we recommend reviewing Breaking Changes to know if any of them causes the behavioral difference.
b. If your project shows compile errors, ensure that a new version of our controls support versions of Visual Studio and Target Framework you are using - see Prerequisites.
c. Always use our Project Converter and follow steps from Upgrade Notes to upgrade your project to a newer version.
Refer to the following article for details: DevExpress WinForms Troubleshooting - Upgrade Projects.
The designed component's layout changes at runtime or setting a property at design-time is not in effect
This issue usually occurs because an old component's layout is restored in your code. Look for the RestoreLayoutFrom~ methods call in your code.
In addition, make sure that you didn't change the component's properties in your code and check that the code of the component's event handlers doesn't affect its layout. To achieve this, comment your code line by line.
General tips to determine what may affect the application behavior
The following factors can cause/affect the issue that you encounter.
-
Environment (remote app, remote desktop connection, add-in/plugin, etc)
Check if the issue is reproduced in a regular environment or it is specific to your custom environment. -
Windows OS
The same app may behave differently on different Windows OSs. Check if it is your case. -
Application culture
If the issue relates to text translations, formatting, or masks, check if it is reproduced with the English culture. -
Control descendant
If you use a DevExpress control's descendant, test your scenario with the ancestor. -
Version of our controls
Ensure you are using the latest version of the DevExpress controls. -
Multi-Threading
Use only thread-safe techniques to safely access controls and their elements. See the following articles for more information: -
Application.DoEvents method
This method can cause issues in some cases. See the following section on this page for more information: A red cross is shown -
Other third-party controls
Temporarily remove all third-party controls from a problematic form to ensure that they do not affect the application behavior.
If the issue still occurs after you've checked all these cases, feel free to submit a ticket to our Support Center and include a small compilable test sample, exception details (if any), reproduction instructions, and expected results into it. Do not hesitate to send screenshots, videos or other additional materials that may be helpful in demonstration of the issue. The complete information will allow our support engineers help you faster.
Hints for preparing a small test compilable project
- Create a test sample with fake in-memory data and include only code that is necessary for reproducing the issue;
- If any custom libraries are really necessary, do not forget to include them as well;
- If you cannot illustrate the issue in a test sample or your application is complex, create a copy of your application and try to remove all the unnecessary modules from there until you obtain a simplified compilable version of your app or, at least, provide us with the Form.Designer.cs/vb and Form.cs/vb files of your "problematic" form.
Search keywords
diagnose, troubleshoot, troubleshooting, how to diagnose, how to troubleshoot