We're sorry GroupDocs doesn't work properply without JavaScript enabled.

Free Support Forum - groupdocs.com

DocumentHandler().AddPassword not works

I am using below code to add password to word documents. it works before but recently it is throwing a exception. on DocumentHandler().AddPassword
this is the exception

Could not load type 'Aspose.Words.LoadOptions' from assembly 'Aspose.Words, Version=22.5.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56'.

Could not load type 'Aspose.Words.LoadOptions' from assembly 'Aspose.Words, Version=22.5.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56'.

here is the my code

using (FileStream fs = new FileStream(FilePath, FileMode.Open))
{
    AddPasswordOptions options = new AddPasswordOptions(FileFormat.Docx, Password);
    GroupDocs.Merger.Domain.Result.DocumentResult result = new DocumentHandler().AddPassword(fs, options);

    fs.Close();
    Stream documentStream = result.Stream;
    var filestream = File.Create(OutputPath);

    documentStream.CopyTo(filestream);
    documentStream.Close();
    filestream.Close();
}

Please help me on this

Thanks
Tilanka

@tilankak

Could you please share a console application using that issue could easily be reproduced at our end? Did you add any Aspose API along-with GroupDocs in your application?

TEST2.zip (4.4 KB)
Hi Tahir

thanks for help

Here is the console app.

Yes I am using aspose api

Thanks
Tilanka

@tilankak

Please follow the following steps and let us know if issue persists:

  • Use latest version of GroupDocs.Merger that is 22.12
  • Aspose APIs versions must not be greater than GroupDocs.Merger’s version when using both APIs together (for example you are using Aspose.Words that is 23.1, please downgrade it to 22.12 or lower)