Exception trying to convert HTML to PDF (Jan 14th 2026)

I am getting the following exception:
[01/14/2026 19:34:01 > 2fe697: INFO] [19:34:01 DBG] Program.ConvertHtmlToPf: Html file ‘C:\home\ConvertHtmlToPdf\Output\whitby-class-upgrade.html’ is created successfully
[01/14/2026 19:34:03 > 2fe697: INFO] [19:34:03 ERR] Error Occurred while generating PDF for project: whitby-class-upgrade.cshtml
[01/14/2026 19:34:03 > 2fe697: INFO] System.AggregateException: One or more errors occurred. (Sequence contains no elements)
[01/14/2026 19:34:03 > 2fe697: INFO] —> System.InvalidOperationException: Sequence contains no elements
[01/14/2026 19:34:03 > 2fe697: INFO] at System.Linq.ThrowHelper.ThrowNoElementsException()
[01/14/2026 19:34:03 > 2fe697: INFO] at System.Linq.Enumerable.First[TSource](IEnumerable1 source) [01/14/2026 19:34:03 > 2fe697: INFO] at Aspose.HTML.Cloud.Sdk.Services.StorageService.<>c__DisplayClass21_0.<<UploadFileAsync>b__0>d.MoveNext() [01/14/2026 19:34:03 > 2fe697: INFO] --- End of stack trace from previous location --- [01/14/2026 19:34:03 > 2fe697: INFO] at Aspose.HTML.Cloud.Sdk.Services.StorageService.UploadFileAsync(String file, String remoteFileUri, String storageName) [01/14/2026 19:34:03 > 2fe697: INFO] at Aspose.HTML.Cloud.Sdk.StorageApi.UploadFileAsync(String file, String remoteFileUri, String storageName) [01/14/2026 19:34:03 > 2fe697: INFO] at Aspose.HTML.Cloud.Sdk.Services.ConversionService.UploadAsync(String folder, String basePath, String[] files) [01/14/2026 19:34:03 > 2fe697: INFO] at Aspose.HTML.Cloud.Sdk.Services.ConversionService.PrepareRequestBodyAsync(ConverterBuilder builder) [01/14/2026 19:34:03 > 2fe697: INFO] at Aspose.HTML.Cloud.Sdk.Services.ConversionService.<>c__DisplayClass12_0.<<ExecuteConversionAsync>b__0>d.MoveNext() [01/14/2026 19:34:03 > 2fe697: INFO] --- End of stack trace from previous location --- [01/14/2026 19:34:03 > 2fe697: INFO] at Aspose.HTML.Cloud.Sdk.Services.ConversionService.ExecuteConversionAsync(ConverterBuilder builder, IObserver1 observer)
[01/14/2026 19:34:03 > 2fe697: INFO] at Aspose.HTML.Cloud.Sdk.Services.ConversionService.ConvertAsync(ConverterBuilder builder, IObserver1 observer) [01/14/2026 19:34:03 > 2fe697: INFO] at Aspose.HTML.Cloud.Sdk.ConvertApi.ConvertAsync(ConverterBuilder builder, IObserver1 observer)
[01/14/2026 19:34:03 > 2fe697: INFO] at Aspose.HTML.Cloud.Sdk.ConvertApi.ConvertAsync(String inputFilePath, IList1 resources, String outputFilePath, ConversionOptions options, IObserver1 observer)
[01/14/2026 19:34:03 > 2fe697: INFO] — End of inner exception stack trace —
[01/14/2026 19:34:03 > 2fe697: INFO] at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
[01/14/2026 19:34:03 > 2fe697: INFO] at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) [01/14/2026 19:34:03 > 2fe697: INFO] at System.Threading.Tasks.Task1.get_Result()
[01/14/2026 19:34:03 > 2fe697: INFO] at ConvertHtmlToPdf.Program.ConvertHtmlToPf(Project project) in C:\Development\Clients\ConvertHtmlToPdf\Program.cs:line 177
[01/14/2026 19:34:03 > 2fe697: INFO] at ConvertHtmlToPdf.Program.GeneratePDFs(List`1 projects) in C:\Development\Clients\ConvertHtmlToPdf\Program.cs:line 131

@devrajbanerjee

  1. The exception System.InvalidOperationException: Sequence contains no elements occurs during the upload of an HTML file to Aspose Cloud Storage, specifically in the UploadFileAsync method . This indicates an issue within the SDK’s internal logic when processing the file upload, likely due to an unexpected empty collection being passed to Enumerable.First() .

  2. A related issue has been reported in the Aspose forum where users encountered a 504 Gateway Timeout error during file uploads and conversions . Such timeouts may reflect temporary server-side problems affecting the Aspose Cloud services, potentially contributing to the failure observed in your case .

  3. Based on the stack trace, the error originates from a call to Enumerable.First() on an empty sequence, suggesting that an operation expected at least one element but found none . This might stem from a failed resource lookup or a misconfigured file path during the conversion process .

To address this issue, consider the following steps:

  • Verify that the HTML file exists at the specified path and is accessible.
  • Confirm that the Aspose Cloud service is operational and not experiencing outages .
  • Retry the conversion after some time, especially if the error correlates with known service disruptions.

If the problem persists, it may be necessary to investigate further into how the SDK handles file uploads or whether there is a bug in the version of the SDK being used. You can also reach out to Aspose support for assistance .

Hi @devrajbanerjee please check if it works for you now