Using Syncfusion in Class Library

I would like to use some Syncfusion objects in a Class Library. The library uses a WPF xaml based user control that I would like to place a Syncfusion datagrid and some charts. However, because this is a class library there aren’t App.xaml or App.xaml.cs files which is where the Syncfusion licensing and registration are added. How do I go about using these tools in this configuration?


3 Replies

SG Santhosh Govindasamy Syncfusion Team February 3, 2025 01:08 PM UTC

Hi Jeffrey,

Thank you for reaching out.


Your requirement can be achieved by registering the license in the UserControl class constructor. For your reference, we have attached a sample. Please review it.

Code Snippet:

public UserControl1()

 {

     Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR LICENSE KEY");

     InitializeComponent();

    

     // Bind Sample Data

     datagrid.ItemsSource = new List<MyData>

     {

         new MyData { ID = 1, Name = "Alice", Age = 25 },

         new MyData { ID = 2, Name = "Bob", Age = 30 },

         new MyData { ID = 3, Name = "Charlie", Age = 35 }

     };

 

     DataContext = new ChartViewModel();

 }


Regards,
Santhosh.G


Attachment: ClassLibrary1_e866d33d.zip


JE Jeffrey February 3, 2025 10:35 PM UTC

Thank you for the reply. Here’s the error I keep getting. Maybe it’s not just the licensing issue?


Could not load file or assembly 'Syncfusion.Shared.Wpf, PublicKeyToken=3d67ed1f87d44c89' or one of its dependencies. The system cannot find the file specified.

 

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> VMS.TPS.Common.Model.ScriptExecutionException: There was a problem while executing the script '\\Client\C$\Users\wd980631\OneDrive - Siemens Healthineers\AQADEX\AQADEX.esapi.dll' (ESAPI: VMS.TPS.Common.Model.API, Version=1.0.350.18, Culture=neutral, PublicKeyToken=305b81e210ec4b89).  ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Windows.Markup.XamlParseException: Could not load file or assembly 'Syncfusion.Shared.Wpf, PublicKeyToken=3d67ed1f87d44c89' or one of its dependencies. The system cannot find the file specified. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Syncfusion.Shared.Wpf, PublicKeyToken=3d67ed1f87d44c89' or one of its dependencies. The system cannot find the file specified.



SG Santhosh Govindasamy Syncfusion Team February 4, 2025 10:51 AM UTC

Hi Jeffrey,

Thank you for your response.


Based on the information you provided, you are experiencing an assembly mismatch issue. Please follow the steps below to resolve the issue:


Solution 1:Kindly remove the "bin" and "obj" folders and rebuild the application.


Solution 2: If you are using NuGet, please ensure that the required assemblies are properly referenced (make sure the assembly versions are the same). If you are referencing assemblies from the build, please ensure that they are properly referenced and that the versions match.


Please note: An exception has been thrown due to the assembly mismatch.


If you continue to face the issue, could you please share the details of the replication procedure? If possible, kindly provide a sample as well; this will be helpful for us to proceed further.


Regards,
Santhosh.G


Loader.
Up arrow icon