Hey Atir,
I work with djsomers and have been looking into this. It seems we are having the same issues as some other users have been getting with the .NET 6 UseReflectionOptimisation NULL reference issues (ASP.NET Core 6.0.7 Support - #13 by bkbejawada & Groupdocs.Assembly - .NET 6).
The issue we’re getting is that the DocumentAssembler.UseReflectionOptimization isn’t starting when we create a new instance of the DocumentAssembler. (we get the same error messages as the support tickets I linked above).
I’ve included our code below. We are using .NET 5 (windows) with GroupDocs.Assembly v22.12
// Here we set up the JSON Data Load Options based on user info
GroupDocs.Assembly.Data.JsonDataLoadOptions options = new GroupDocs.Assembly.Data.JsonDataLoadOptions();
switch (Message.Documents[0].PowerPointJsonParseMode)
{
case PowerPointJsonParseMode.Loose:
options.SimpleValueParseMode = GroupDocs.Assembly.Data.JsonSimpleValueParseMode.Loose;
break;
case PowerPointJsonParseMode.Strict:
options.SimpleValueParseMode = GroupDocs.Assembly.Data.JsonSimpleValueParseMode.Strict;
break;
default:
options.SimpleValueParseMode = GroupDocs.Assembly.Data.JsonSimpleValueParseMode.Loose;
break;
GroupDocs.Assembly.Data.JsonDataSource ds = new GroupDocs.Assembly.Data.JsonDataSource(stream, options);
GroupDocs.Assembly.DocumentAssembler engine = new GroupDocs.Assembly.DocumentAssembler();
// Here I was attempting to either start the optimizer manually, or set it to false. Neither worked as was NULL
DocumentAssembler.UseReflectionOptimization = new();
// Here we set some more options
if (Message.Documents[0].PowerPointAllowMissingMembers == true)
{
engine.Options |= GroupDocs.Assembly.DocumentAssemblyOptions.AllowMissingMembers;
}
if (Message.Documents[0].PowerPointRemoveEmptyParagraphs == true)
{
engine.Options |= GroupDocs.Assembly.DocumentAssemblyOptions.RemoveEmptyParagraphs;
}
if (Message.Documents[0].PowerPointInlineErrorMessages == true)
{
engine.Options |= GroupDocs.Assembly.DocumentAssemblyOptions.InlineErrorMessages;
}
// And then finally we attempt to assemble the document
engine.AssembleDocument(
Message.Documents[0].FilePath,
RDoc.FilePath,
new GroupDocs.Assembly.LoadSaveOptions(GroupDocs.Assembly.FileFormat.Pptx),
new DataSourceInfo(ds));
I have read through the other support tickets on this and I have added the referenced projects that you ask for (We already use the Aspose libraries in our solution, so the references were already present when we added our reference for GroupDocs)
One thing that may be of note, we have to target a windows specific build for our solution (we have functions that rely on a full version of windows/windows forms)
<TargetFramework>net5.0-windows</TargetFramework>
<ItemGroup>
<PackageReference Include="AngleSharp" Version="0.16.1" />
<PackageReference Include="Aspose.BarCode" Version="22.10.0" />
<PackageReference Include="Aspose.CAD" Version="22.10.0" />
<PackageReference Include="Aspose.Cells" Version="22.11.0" />
<PackageReference Include="Aspose.Diagram" Version="22.10.0" />
<PackageReference Include="Aspose.Email" Version="22.9.0" />
<PackageReference Include="Aspose.HTML" Version="22.9.0" />
<PackageReference Include="Aspose.Imaging" Version="22.10.0" />
<PackageReference Include="Aspose.Note" Version="22.9.0" />
<PackageReference Include="Aspose.OCR" Version="22.9.0" />
<PackageReference Include="Aspose.PDF" Version="22.10.0" />
<PackageReference Include="Aspose.Slides.NET" Version="22.10.0" />
<PackageReference Include="Aspose.Tasks" Version="22.10.0" />
<PackageReference Include="Aspose.Words" Version="22.10.0" />
<PackageReference Include="Aspose.Words.Shaping.HarfBuzz" Version="22.10.0" />
<PackageReference Include="Aspose.Zip" Version="22.9.0" />
<PackageReference Include="GroupDocs.Assembly" Version="22.12.0" />
We also set up a Metered License in the Startup of our API (again, we already use Aspose in our solution so we already have a metered license set up function, present)
GroupDocs.Assembly.Metered groupDocsLic = new GroupDocs.Assembly.Metered();
string _asposeLicenseMeteredPublic = Configuration["PATHTOLICENSEKEY"];
string _asposeLicenseMeteredPrivate = Configuration["PATHTOLICENSEKEY"];
groupDocsLic.SetMeteredKey(_asposeLicenseMeteredPublic, _asposeLicenseMeteredPrivate);
I’ve tried the steps mentioned in the other support tickets around this, but no change. I have also downloaded the Console application you supplied above and that works, so not sure as to what this issue could be
Thanks,
Charlie