Problem upgrading from gcWord to DSWord

Posted by: david.sheppard on 2 February 2024, 6:55 am EST

    • Post Options:
    • Link

    Posted 2 February 2024, 6:55 am EST - Updated 2 February 2024, 7:00 am EST

    I followed the migration instructions. I removed the grapecity.documents using the nuget 'manage packages for solution in visual studio. Then I added the four DS.Documents packages listed in the migration instructions.

    I did not change anything else in my solution. When my code gets to the following statement, I get the error “type initializer for ‘GrapeCity.Documents.Word.DocumentBase’ threw an exception”.

    Doc1 As New GrapeCity.Documents.Word.GcWordDocument

  • Posted 4 February 2024, 6:52 pm EST

    Hello David,

    We do not face this issue at our end, as shown in the attached GIF.

    Please take a look into it and let us know if you are doing anything differently.

    Regards,

    Prabhat Sharma.

  • Posted 4 February 2024, 6:52 pm EST - Updated 4 February 2024, 6:57 pm EST

  • Posted 6 February 2024, 7:19 am EST

    Below is the error that is occurring. The message says it is a problem with the DocumentFormat.OpenXml. The two ‘inner exception’ messages refer to different versions of the file. Version 2.20.0.0 is what was loaded when DS.Word was loaded in nuget.

    System.TypeInitializationException

    HResult=0x80131534

    Message=The type initializer for ‘GrapeCity.Documents.Word.DocumentBase’ threw an exception.

    Source=DS.Documents.Word

    Inner Exception 1:

    FileNotFoundException: Could not load file or assembly ‘DocumentFormat.OpenXml, Version=3.0.1.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17’ or one of its dependencies. The system cannot find the file specified.

    Inner Exception 2:

    FileNotFoundException: Could not load file or assembly ‘DocumentFormat.OpenXml, Version=2.20.0.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17’ or one of its dependencies. The system cannot find the file specified.

  • Posted 6 February 2024, 2:19 pm EST

    Hello David,

    It might be a dependency-related issue that you are using in your project.

    Please share the list of dependencies you are using in your project with their versions.

    You can also check if you are facing the same issue with the attached stripped-down sample and let us know your observation.

    Regards,

    Prabhat Sharma.

    GcWordMigrationTest.zip

  • Posted 6 February 2024, 10:31 pm EST - Updated 6 February 2024, 10:36 pm EST

    The project is a 4.6.2 dot net framework. Attached is a screen capture from of the references.

    Thank you for your help with this.

  • Posted 7 February 2024, 11:10 pm EST

    Hello David,

    As per your given screenshot, it seems you are using Spread.NET 16 and DsWord 7.0.2 in the project.

    So we have tried adding both but the issue is still not replicating at our end.

    Please find the attached sample and let us know if it is throwing the same issue at your end. If it is not then please modify it accordingly, replicating the issue, so that we can assist you further accordingly.

    You can also check if you are facing the same issue with the attached stripped-down sample and let us know your observations.

    Regards,

    Prabhat Sharma.

    TestBuild.zip

  • Posted 17 February 2024, 11:26 pm EST

    I tried everything that you suggested and nothing worked. The issue was reported as a dll conflict between 2 versions of DocumentFormat.OpenXml, but I could not find any reference to more than one version. I decided to start over with the solution.

    I fixed the issue by creating a new solution and then adding all the forms, modules, datasets, and classes from the the other solution. I added the references to spread first, then I added DS.Word using the nuget solution tool. Then, I added the other references for the solution (mostly Microsoft). When I finished the solution ran and the DS.Word tool worked. It was a lot of work, but successful in the end.

    Thank you again for your help.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels