Cheat Sheets, Best Practices and Troubleshooting
This article describes most common issues you may face when you use DevExpress components to create add-ins for third-party applications.
Known Issues
Issue 1: An add-in conflicts with the main application or with other add-ins. An exception occurs.
Below are examples of exceptions you can encounter:
- [A] cannot be cast to [B]. Type A originates from 'X' in the context 'Default' at location…
- It is not possible to convert [A] DevExpress.Utils.Svg.SvgImage to [B] DevExpress.Utils.Svg.SvgImage. Type A originates from…
- Method not found: …
Cause
This behavior is related to the way .NET runtime loads assemblies. An application uses the version of an assembly that is loaded first. Type-related errors can be raised when a third-party application (the main application) and add-in, or some different add-ins use different versions of the same assembly.
Solution
Please refer to the following MSDN articles for more information:
- How the Runtime Locates Assemblies;
- Best Practices for Assembly Loading
- Consider Using the .NET Framework Add-In Model
Do not use different versions of the same assembly in one application domain.
Issue 2: Data binding issues. Components don't display data.
Cause
DevExpress components use the standard data binding mechanism. They rely on the BindingContext object to handle data-aware operations. If a control does not display data once you assigned a data source, it's likely that the BindingContext is not applied. This often takes place if our components are used outside the .NET environment (e.g., in VSTO Add-Ins) where BindingContext doesn't exist. See the following thread where we discussed a similar issue: Problem with XtraGrid within a PowerPoint VSTO Add-in.
Solution
The simplest solution is to assign the BindingContext manually:
C#gridControl.BindingContext = <parent form>.BindingContext;
//or
gridControl.BindingContext = new BindingContext();
See also:
DevExpress WinForms Troubleshooting - Data Binding Issues
Issue 3: Component's size settings (size, font or scaling) are different at design time and runtime
Cause
When .NET controls are used in a standard WinForms application, they are scaled by the system. When controls are used in an add-in, they are scaled by the third-party application.
Solution
- Try using a different DPI Awareness Mode. Please refer to the following help article for details Graphics Performance and High DPI.
- If it doesn't help, check whether the issue is reproduced with the standard components in a test project. If the issue persists, search for the solution on the web, Stack Overflow, or contact the application vendor.
- If the issue occurs only when you are using DevExpress components, look for a solution in our Search Engine or create a new ticket in our Support Center. Please share as much information as possible (a screenshot, a video or a project where the issue is reproducible). This information will help us determine the cause of the issue in the fastest and most straightforward way.
Issue 4: A popup menu or drop-down window closes immediately after you release the mouse button
Cause
This issue is not directly related to our components. The cause of the problem can be that the same mouse messages are sent twice when a .NET component is used outside .NET environment. Please refer the following threads where we discussed a similar issue:
GridView PopupMenu instantly closing
Popup menu disappears on releasing mouse in Word VSTO addin
Solution
Try calling the DevExpress.XtraBars.MessageFilter.BarManagerHook.FilterMouseEvents method:
C#DevExpress.XtraBars.MessageFilter.BarManagerHook.FilterMouseEvents();
Issue 5: The "System.InvalidOperationException: "The current SynchronizationContext may not be used as a TaskScheduler" or other exceptions related to SynchronizationContext
Cause
This issue is not related to our components directly. It usually occurs when our components that implement asynchronous functionality using TaskScheduler (Instant Feedback Mode, Scaffolding, etc.) are used in Office add-ins because the standard SynchronizationContext.Current property returns Null. However, you may obtain the same issue when you use the standard TaskScheduler class in your code. Please refer to the following Stack Overflow discussions:
The current SynchronizationContext may not be used as a TaskScheduler
Hooked events Outlook VSTO continuing job on main Thread
Solution
Create and set WindowsFormsSynchronizationContext manually when initializing your add-in as follows:
C#System.Threading.SynchronizationContext.SetSynchronizationContext(new WindowsFormsSynchronizationContext());
The issue is not on the Known Issues list
If the issue you faced is not described above, try doing the following:
- Check whether the issue occurs with the standard components. For this, add a standard component to your add-in and run it. If you obtain the same behavior, look for similar issues, errors, and solutions on the web, Stack Overflow, or contact the application's vendor Support Team.
- If the issue occurs only when you are using our components, look for a solution in our Search Engine or create a new ticket in our Support Center. Please share as much information as possible (a screenshot, a video or a project where the issue is reproducible). This information will help us determine the cause of the issue in the fastest and most straightforward way.