I got this error Error CS0433 The type 'WordDocument' exists in both 'Syncfusion.DocIO.Base, Version=19.2400.0.48, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89' and 'Syncfusion.DocIO.ClientProfile, Version=19.2400.0.49, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89' while trying to add this code.
//Creates a new Word document
WordDocument document = new WordDocument();
//Adds one section and one paragraph to the document
document.EnsureMinimal();
//Appends a new mathematical equation to the paragraph
WMath math = document.LastParagraph.AppendMath();
//Adds a new math
IOfficeMath officeMath = math.MathParagraph.Maths.Add();
//Adds a fraction equation
IOfficeMathFraction mathFraction =
officeMath.Functions.Add(0, MathFunctionType.Fraction) as IOfficeMathFraction;
//Sets the denominator for fraction
IOfficeMathRunElement officeMathRunElement =
mathFraction.Numerator.Functions.Add(0, MathFunctionType.RunElement) as IOfficeMathRunElement;
officeMathRunElement.Item = new WTextRange(document);
(officeMathRunElement.Item as WTextRange).Text = "a";
//Sets the numerator for fraction
officeMathRunElement =
mathFraction.Denominator.Functions.Add(0, MathFunctionType.RunElement) as IOfficeMathRunElement;
officeMathRunElement.Item = new WTextRange(document);
(officeMathRunElement.Item as WTextRange).Text = "b";
//Sets the fraction type
mathFraction.FractionType = MathFractionType.NormalFractionBar;
//Saves the Word document
document.Save("Sample.docx", FormatType.Docx);
//Closes the document
document.Close();
Hi Olayinka,
From the given details, we have
found that the two (Syncfusion.DocIO.Wpf
and Syncfusion.DocIO.ClientProfile) NuGet packages
are referred in your WPF platform application. So, you have faced the reported
problem at your end. For your reference, we have prepared the sample to refer
the NuGet packages properly in the application and it can be downloaded from
the below attachment.
To resolve the reported issue, we suggest you to install “Syncfusion.DocIO.ClientProfile”
NuGet package if you are using the target framework as “.NET Framework 3.5 or
4.0 Client Profile” in your application. Otherwise, install “Syncfusion.DocIO.Wpf”
NuGet package based on the platform.
Please find the details from the below table,
|
Platform(s) |
Package name |
Package manager console command |
|
Windows Forms, Console Application (Targeting .NET Framework) |
Syncfusion.DocIO.WinForms.nupkg |
Install-Package Syncfusion.DocIO.WinForms |
|
WPF |
Syncfusion.DocIO.Wpf.nupkg |
Install-Package Syncfusion.DocIO.Wpf |
|
.NET Framework 3.5 or 4.0 Client Profile |
Syncfusion.DocIO.ClientProfile.nupkg |
Install-Package Syncfusion.DocIO.ClientProfile |
Please refer our UG documentation to
know about the NuGet packages need to be installed in your application,
https://help.syncfusion.com/file-formats/docio/nuget-packages-required
Regards,
Anto Nihil S
It is a winform application. I used sfrichtextboxadv.wpf using element host. So the nuget packages were installed by automatically by themselves.
How can this be resolved?
Hi Olayinka,
Currently, we are investigating the reported problem and will update you with
more details on 30th June 2022.
Could you please share the target framework of your Windows Form application?
Regards,
Anto Nihil S
.NET Framework 4
Hi Olayinka,
We can reproduce the reported issue with “Error is thrown on using sfrichtextboxadv.wpf in WinForm application of .NET
Framework 4”, will validate and update you with further details on 30th June 2022.
Regards,
Kalaivannan Ganesan
Ok.
But i would also like to add that when Ctrl+Shift+ < or > is pressed without selecting a text in sfrichtextboxadv, it displays error specified cast is not valid.
Hi Olayinka,
Regarding the error specified cast is not valid:
We have already fixed the reported issue
and have been moved to Volume 2 2022 main release, it is estimated to be
available on 1st July 2022. We will notify you once it has been
released.
Regarding Error is thrown on using sfrichtextboxadv.wpf in WinForm application:
We are still validating this issue and we will update you with further details
on 4th July 2022.
Regards,
Kalaivannan Ganesan
Hi Olayinka,
Regarding the error specified cast is not valid:
We have included the fix for this
reported issue in our Essential Studio 2022 Volume 2 Main Release V20.2.0.36 is rolled out and is available for download under the following link.
https://www.syncfusion.com/forums/175975/essential-studio-2022-volume-2-main-release-v20-2-0-36-is-available-for-download
Regarding Error is thrown on using sfrichtextboxadv.wpf in WinForm application:
As We mentioned earlier, still validating this issue and we will update you
with further details on 4th July 2022.
Regards,
Kalaivannan Ganesan
Ok... Can I get the updates from nuget packages as well?
Hi Olayinka,
Regarding the error specified cast is not valid:
The fix for the
reported issue has been included in our latest weekly NuGet (v.20.2.0.36). You
can use that latest NuGet to get resolve this issue at your end.
Regarding Error is thrown on using sfrichtextboxadv. wpf in WinForm application:
We are validating this issue with high priority and we will update you with
further details on or before 6th July 2022.
Regards,
Kalaivannan Ganesan
Hi Olayinka,
To
avoid this assembly conflict in your project, we request you to use the extern
alias feature in .NET which allows you to give referenced Nugets an alias and use the alias for the respective elements.
The Alias can be set through that Aliases property in the property window for
any referenced Nuget libraries as shown below.
|
|
And created a sample to demonstrate the same,
which can be downloaded from the below location
https://www.syncfusion.com/downloads/support/forum/175476/ze/SFRICH~1-1774618070
Please
let us know if you have any other questions.
Regards,
Kalaivannan
Ganesan