Has anyone been able to create a palette of custom Symbols in the Symbol Designer, and then been able to successfuly load that Palette by compiling the VB version of the Diagram Builder?
I keep getting the same message:
Unable to cast object of type 'Syncfusion.Windows.Forms.Diagram.SymbolPalette' to type 'Syncfusion.Windows.Forms.Diagram.SymbolPalette'.
The error is inside biAddPalette, the offending line of code is:
curSymbolPalette = CType(formatter.Deserialize(iStream), SymbolPalette)
Any help in this would be greatly appreciated.
If anyone has been successful, can you post what build # you are using?
I've tried v4 of 2008 as well as the lastest version 2009, VS Studio 2008 Pro.
Thanks in advance,
Glenn
GM
Glenn Miller
January 20, 2009 01:36 AM UTC
Decided to look at several versions of the code.
Found that after defining the formatter as BinaryFormatter, the following line of code is required:
formatter.Binder = Syncfusion.Runtime.Serialization.AppStateSerializer.CustomBinder
Now I can load custom Palettes in the sample application (my assumption is that a similar line will be required in C# as well.
Issue closed for me.
Glenn
>Has anyone been able to create a palette of custom Symbols in the Symbol Designer, and then been able to successfuly load that Palette by compiling the VB version of the Diagram Builder?
I keep getting the same message:
Unable to cast object of type 'Syncfusion.Windows.Forms.Diagram.SymbolPalette' to type 'Syncfusion.Windows.Forms.Diagram.SymbolPalette'.
The error is inside biAddPalette, the offending line of code is:
curSymbolPalette = CType(formatter.Deserialize(iStream), SymbolPalette)
Any help in this would be greatly appreciated.
If anyone has been successful, can you post what build # you are using?
I've tried v4 of 2008 as well as the lastest version 2009, VS Studio 2008 Pro.
Thanks in advance,
Glenn
AM
Ajeet M
Syncfusion Team
January 20, 2009 04:48 AM UTC
Hi Glenn,
Yes, you are absolutely correct with your code snippet.
The problem why you were not able to open the palette created in Symbol designer application into the Diagram Builder sample was that, both of these applications were compiled seperately in different framework assemblies.
Symbol Designer was pre-compiled with framework 2.0 and Diagram Builder with framework assemblies in the GAC or public assembly folder; in your case with v3.5 framework.
To test this, you may open the created palette, in the diagram builder sample with framework 2.0 assemblies version perfectly.
However, I assure you that the code snippet will be included in the upcoming build releases and this shall be fixed very soon.
Thanks for your time,
Warm Regards,
Ajeet
LZ
Ljubo Zizic
April 20, 2009 10:30 AM UTC
I am having this problem with my project and adding line:
formatter.Binder = Syncfusion.Runtime.Serialization.AppStateSerializer.CustomBinder
didnt solve the problem i still get the same exception.
I tried to change framework version to 2.0 in my project but that didnt help either..
Any other suggestions?
>Hi Glenn,
Yes, you are absolutely correct with your code snippet.
The problem why you were not able to open the palette created in Symbol designer application into the Diagram Builder sample was that, both of these applications were compiled seperately in different framework assemblies.
Symbol Designer was pre-compiled with framework 2.0 and Diagram Builder with framework assemblies in the GAC or public assembly folder; in your case with v3.5 framework.
To test this, you may open the created palette, in the diagram builder sample with framework 2.0 assemblies version perfectly.
However, I assure you that the code snippet will be included in the upcoming build releases and this shall be fixed very soon.
Thanks for your time,
Warm Regards,
Ajeet
AD
Administrator
Syncfusion Team
April 21, 2009 01:28 PM UTC
Hi,
The problem that you are facing can be solved by pasting the one line of code given below.
formatter.Binder = Syncfusion.Runtime.Serialization.AppStateSerializer.CustomBinder;
Place the above code inside the fuction of MainForm.cs file of Symbol Desingner
private SymbolPalette OpenPaletteFile( string strFileName )
and just between the following codes
IFormatter formatter = new BinaryFormatter();
----Place the code here ----
try
Now open the palette file and you can see the problem getting solved.
Regards,
Gowri
LZ
Ljubo Zizic
November 4, 2009 01:15 PM UTC
Hi, this is my code snippet below. I get that same error message even though I inserted that line:
formatter.Binder = Syncfusion.Runtime.Serialization.AppStateSerializer.CustomBinder
Please help.
Code snippet:
Dim palettepath As String = "C:\Lolic\projekti\Diplomski aplikacija NIS\Diplomski aplikacija NIS 20091027\palete\svjetlovodi.edp"
Dim palette As Syncfusion.Windows.Forms.Diagram.SymbolPalette = LoadPalette(palettepath)
For Each node As Node In palette.Nodes
Dim nodeToInsert As Syncfusion.Windows.Forms.Diagram.Node = DirectCast(node.Clone(), Syncfusion.Windows.Forms.Diagram.Node)
DiagramNIS.Model.AppendChild(nodeToInsert)
Next
Public Function LoadPalette(ByVal filename As String) As Syncfusion.Windows.Forms.Diagram.SymbolPalette
Dim curSymbolPalette As Syncfusion.Windows.Forms.Diagram.SymbolPalette = Nothing
Dim iStream As New IO.FileStream(filename, FileMode.Open, FileAccess.Read)
If iStream IsNot Nothing Then
Dim formatter As Runtime.Serialization.IFormatter = New Runtime.Serialization.Formatters.Binary.BinaryFormatter()
formatter.Binder = Syncfusion.Runtime.Serialization.AppStateSerializer.CustomBinder
Try
curSymbolPalette = DirectCast(formatter.Deserialize(iStream), Syncfusion.Windows.Forms.Diagram.SymbolPalette)
AddHandler AppDomain.CurrentDomain.AssemblyResolve, AddressOf Syncfusion.DiagramBaseAssembly.AssemblyResolver
Catch generatedExceptionName As Runtime.Serialization.SerializationException
Try
formatter = New Runtime.Serialization.Formatters.Soap.SoapFormatter()
formatter.Binder = Syncfusion.Runtime.Serialization.AppStateSerializer.CustomBinder
iStream.Position = 0
curSymbolPalette = DirectCast(formatter.Deserialize(iStream), Syncfusion.Windows.Forms.Diagram.SymbolPalette)
Catch e As Exception
System.Diagnostics.Trace.WriteLine("Error reading SymbolPalette", e.Message)
End Try
Finally
iStream.Close()
End Try
End If
Return curSymbolPalette
End Function
DS
Daniel Santos de Carvalho
September 23, 2010 12:42 PM UTC
I have the same problem, using VS2008 and C#. It works fine with the "Text Symbols.edp" of the example, but don't work with my .edp
IFormatter formatter = new BinaryFormatter();
formatter.Binder = Syncfusion.Runtime.Serialization.AppStateSerializer.CustomBinder;
try
{
AppDomain.CurrentDomain.AssemblyResolve +=
new ResolveEventHandler Syncfusion.DiagramBaseAssembly.AssemblyResolver);
curSymbolPalette = (SymbolPalette)formatter.Deserialize(iStream);
}