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

Unable to cast object of type 'Syncfusion.Windows.Forms.Edit.Implementation.Config.ConfigLanguage' error.

I am following the instructions here: https://help.syncfusion.com/windowsforms/syntax-editor/syntax-highlighting#apply-custom-configuration-in-editcontrol

Here's my code:

private string editControlConfig = Path.GetDirectoryName(Application.ExecutablePath) + @"\..\..\config.xml";

EDITC_SVGSource.Configurator.Open(editControlConfig);
EDITC_SVGSource.ApplyConfiguration("xml");
EDITC_SVGSource.LoadFile(DLOG_OpenSVGFile.FileName);

When I run my application, I get the following error:


Exception thrown: 'System.InvalidCastException' in System.Private.CoreLib.dll
An exception of type 'System.InvalidCastException' occurred in System.Private.CoreLib.dll but was not handled in user code
Unable to cast object of type 'Syncfusion.Windows.Forms.Edit.Implementation.Config.ConfigLanguage' to type 'Syncfusion.Windows.Forms.Edit.Implementation.Config.ConfigLanguage[]'.


Here's a screenshot:

devenv_fYM2xdagne.png

 
What am I doing wrong here? This is a C# solution targeting .NET 7.0, using Visual Studio 2022 with all the required Syncfusion assemblies installed.



3 Replies

KA Karthick Arjunan Syncfusion Team March 17, 2023 01:57 PM UTC

Hi Joseph,


We were unable to reproduce the reported issue. We have attached the tested sample for your reference, in which it works fine without any exception. Could you please provide more details such as a complete code snippet or revert us with modify the attached sample in the reproduced state that will be helpful us to provide the solution as soon as possible.


Attachment: EditControlConfigPathDemo_d3627d4.zip


JS Joseph Sorensen March 18, 2023 12:15 PM UTC

Your solution works properly on my end. I don't know why mine doesn't.

I've uploaded my solution to this post. Maybe that will help you narrow down what's going wrong.

Excuse the awful syntax, I am still learning C#.


Attachment: SVGTweakBeta_ee1d372c.7z


KA Karthick Arjunan Syncfusion Team March 20, 2023 12:51 PM UTC

Joseph,

After analyzing your sample, we find out the issue in Config.xml file. To resolve this issue, you should add the ConfigLanguage tag inside the ArrayOfConfiguration tag in the config.xml file as per the below code snippet.


<ArrayOfConfigLanguage>

<ConfigLanguage name="xml">

 

<formats>

<format name="Text" Font="Input, 13pt"/>

</formats>

 

<extensions>

</extensions>

 

<lexems>

</lexems>

 

<splits>

</splits>

 

    </ConfigLanguage>

</ArrayOfConfigLanguage>


We have also attached the modified sample for your requirement. Please download the sample in the attachment and let us know if you have any other queries.


Attachment: SVGTweakBeta_ee1d372c_4496b6d0.zip

Loader.
Up arrow icon