@Niteen_Jadhav
As far as following error is concerned:
|Error|CS0121|The call is ambiguous between the following methods or properties: 'PreviewOptions.PreviewOptions(PreviewOptions.CreatePageStream, params int[])' and 'PreviewOptions.PreviewOptions(PreviewOptions.CreateDocPageStream, params int[])'
The issue is that the PreviewOptions
class has two constructors:
PreviewOptions(PreviewOptions.CreatePageStream, params int[])
: This constructor takes a PreviewOptions.CreatePageStream
delegate and an optional array of page numbers.
PreviewOptions(PreviewOptions.CreateDocPageStream, params int[])
: This constructor takes a PreviewOptions.CreateDocPageStream
delegate and an optional array of page numbers.
In your code, you’re passing pageNumber => result
as the first argument, which could match either of the constructors. Hence, causing the ambiguity.
To fix this issue, you need to explicitly specify which constructor you want to use. You can do this by casting the lambda expression to the appropriate delegate type:
MemoryStream result = new MemoryStream();
PreviewOptions previewOption = new PreviewOptions((PreviewOptions.CreatePageStream)((int pageNumber) => result), new[] { 1 });
In this example, we cast the lambda expression (int pageNumber) => result
to the PreviewOptions.CreatePageStream
delegate, which resolves the ambiguity and allows the code to compile.
Alternatively, you can also try using the PreviewOptions.CreateDocPageStream
delegate if that’s more appropriate for your use case:
MemoryStream result = new MemoryStream();
PreviewOptions previewOption = new PreviewOptions((PreviewOptions.CreateDocPageStream)((int pageNumber) => result), new[] { 1 });
By doing this the error will go away but you may face some warnings. To address those warnings, we have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): TOTALNET-104
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.