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
close icon

MySymbol

I have been trying to create my own Symbol, using your example :
ms-help://MS.VSCC.v80/Syncfusion/SfDiagramBase/Symbols1.html

But when I try to use it, an unknown exception is handle :

" Server Error in '/solution' Application.
--------------------------------------------------------------------------------

Type 'MySymbol' in Assembly 'App_Web_kwx1gkv4, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.Serialization.SerializationException: Type 'MySymbol' in Assembly 'App_Web_kwx1gkv4, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

Source Error:

The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:

1. Add a "Debug=true" directive at the top of the file that generated the error. Example:

<%@ Page Language="C#" Debug="true" %>

or:

2) Add the following section to the configuration file of your application:







Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.

Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario."


This is the code I use:
Dim insCmd_Poly As InsertNodesCmd = New InsertNodesCmd()
Dim poly1 As MySymbol = New MySymbol()
insCmd_Poly.AddNode(poly1, New PointF(50, 30))
insCmd_Poly.Do(Me.DiagramWebControl1.Model)

Do I forget something?


2 Replies

J. J.Nagarajan Syncfusion Team April 7, 2007 04:33 PM UTC

Hi Dupleix,

Thanks for using Syncfusion product.

You have to add Serialization constructor and Serialization state information to your custom symbol. Please add the following codes in your custom symbol to resolve your problem

[Serializable()]
public class MySymbol : Symbol
{
public MySymbol()
{
//Add your custom symbol code here
}
// Serialization constructor for symbols.
protected override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
}
// Called when deserialization is complete.
protected override void OnDeserialization(object sender)
{
base.OnDeserialization(sender);

// Get references to the child objects
this.outerRect = this.GetChildByName("Rectangle") as Syncfusion.Windows.Forms.Diagram.Rectangle;
this.innerEllipse = this.GetChildByName("Ellipse") as Ellipse;
}

I have attached my Custom Symbol file for your reference. Please refer to this MySymbol Class and Serialization constructor for symbols.

Also refer to our ScriptyClient sample (C:\Program Files\Syncfusion\Essential Studio\4.4.0.51\Web\diagram.web\Samples\2.0\ScriptyClient) for more details. In this sample when yiu click on the "Add Symbol" button, you can add a button to the DiagramWebControl.

I hope this will resolve your problem. Let me know if you have any questions.

Thanks,
Nagaraj
CustomSymbol.zip



FD Foucault Dupleix April 10, 2007 07:06 AM UTC

It worked, thanks a lot

Loader.
Live Chat Icon For mobile
Up arrow icon