We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Diagram Control errors with used with threads

I am using the Windows Diagram control to generate image files from diagrams that are generated through code in batch. However, I have problems because it turns out that the application that initiates my program is using a multiple threading apartment model (MTA). When I create a STA thread, I can only generate one diagram. Subsequent attempts to create diagrams errors.

The application works great when attached to a form for testing or from a console using a single threaded apartment (STA). I do not have a diagram control on a form. I use a self-contained class that creates a diagram control, draws the diagram and then saves the image.

When the class is then accessed through an external assembly, which is a console command, errors start occurring. I cannot seem to work through these errors because they are too deep into "Syncfusion.Diagram.Base".

The errors all start with the threaded apartment state. If the console command has a state of STA, no issues occur. However, if the state is MTA the problems start. I cannot control the state and it will be set to MTA. Below is a description of what has taken place.

I simply do not know what to do next. Any advice on what to do next will be appricated. I attached a demostration of the issue with a readme file that contains the specific errors.

-----------------------------------------------

- ROUND ONE -
The first time my class was created by the console command. I received “DragDrop registration did not succeed" (ERROR 1 - in readme.txt. Research tells me the source of this error is related to Windows Forms when the thread apartment state is in MTA mode.


- ROUND TWO -
I then spun a new STA thread to create the image. This worked fine for the first pass. However, if more than one diagram is created an Object Not Set error occurs. In other words, if I attempt to create a second instance of the diagram control, then I get an "Object reference not set to an instance of an object." (ERROR 2 - in readme.txt) on the following line of code.

Dim diagram = New Syncfusion.Windows.Forms.Diagram.Controls.Diagram

This error occurs regardless of how I attempt to dispose or set the diagram object to nothing, so a brand new instance of the object can be created from scratch. I attempted to clear out the diagram object from memory and start a new thread. Still get the error.


- ROUND THREE -
I attempted to keep the diagram control object declared and reuse it on the second pass. On the first pass the process worked fine. However once again on the second pass it errors. However, now the error is in the symbol not the diagram control. There are various "Object reference not set to an instance of an object" errors (ERROR 3 - in readme.txt) when adding label or nodes to the symbol. I have gotten further because I have a diagram object to use, but I cannot work with the symbols.




DiagramTestLibrary.zip

1 Reply

J. J.Nagarajan Syncfusion Team April 23, 2007 08:08 PM UTC

Hi Michael,

I was able to reproduce this issue in v.4.4.0.51. We have internally fixed this issue . Please create a Direct-Trac incident (mention the forum link in the subject line) so that we can update with the download link of the private patch including this fix.

Please let me know if you have any questions.

Thanks for using Syncfusion product.

Regards,
Nagaraj

Loader.
Live Chat Icon For mobile
Up arrow icon