NullReferenceException in ActiproSoftware.UIStudio.Dock.Net2

Docking/MDI for Windows Forms Forum

Posted 13 years ago by 7Alpha7
Version: 2.0.0111
Platform: .NET 4.0
Environment: Windows 7 (32-bit)

I have a problem with the activation of DocumentWindow while several threads are running. I have a document taking a long time to load; so I load it in a separate thread.

- The first DocumentWindow is instanciated with the ctor()
- The first DocumentWindow creates a thread in the OnCreateControl() override and performs some load and initialization stuff
- Since my app UI is available I open a second DocumentWindow
- The second DocumentWindow is instanciated with the ctor()
- The second DocumentWindow performs on the same thread some initialization stuff on OnCreateControl() override
- The second DocumentWindow calls Activate(true)

=> then a NullReferenceException is thrown :

ActiproSoftware.UIStudio.Dock.DockManager.b(TabbedMdiWindow A_0)
   à ActiproSoftware.UIStudio.Dock.DocumentWindow.Activate(Boolean focus)

Comments (3)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
You need to be very careful whenever doing threading since you should not access any UI elements from anything but the primary UI thread. I would say you should review your code again and make sure you are not calling DocumentWindow methods from your secondary thread. If you are, you should change those and it will likely help.

If that doesn't do the trick, then please make a simple sample project that shows the issue and email it to our support address. Don't include any .exe files in the ZIP and rename the .zip file extension so it doesn't get spam blocked.

Actipro Software Support

Posted 13 years ago by 7Alpha7
I do not acces UI elements from another thread than the main thread. If I would, an exception would be thrown anyway in the Windows stack, not the Actipro one.

Everywhere in my code I have UI calls routed to the main thread because my app uses many different threads. So I have generic routing to the right thread each time I need to use the UI.

In that precise case it fails because of Activate call, not because of UI call on the wrong thread.

I have not the time to prepare a sample project. But the steps are straigtforward :

=> create a DocumentWindow1 on the main thread
=> make a long call in another thread inside DocumentWindow1.OnCreateControl
=> during this call create a DocumentWindow2 on the main thread
=> call DocumentWindow2.Activate
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
We can add null checks into that method where it's happening however before we do so we really need to solve what is causing this to begin with. Adding null checks will mask the issue and there likely would be missing functionality as a result of the problem not really being fixed.

Thus we do need a simple sample project from you that shows this happening since nobody else has reported this, and it is likely something related to your threading.

Actipro Software Support

The latest build of this product (v24.1.0) was released 4 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.