Publishing extensions to Business Central OnPremises and "Sequence contains no elements"

Error: Sequence contains no elements

In previous blog post I described about the installation process in On-Premises environments. I declared that it is recommended to install the extensions to product environment with PowerShell, but I did not clarify the issue any further.

If extensions are installed as a mixed set, some extensions with PowerShell and some extensions with Visual Studio Code, everything is ok until you have dependencies declared.

If base extension is installed with Visual Studio Code, and later you try to install a depending extension with PowerShell, you will run into bit cryptic error:

Publishing SQ Document layout templates version 1.0.35916.19
Publish-NAVApp : Extension compilation failed
error AL1024: A package with publisher 'Solteq', name 'SQ Customer Finland Business Logic', and a version compatible with '1.0.35916.28' could not be loaded. Sequence contains no el

This error is caused by the difference between how PowerShell and Visual Studio Code do the installation process. Because there is no better explanation for it, I have come to a conclusion that PowerShell somehow "finalises" the installation, does something that Visual Studio Code does not do, and later PowerShell installations require this "finalisation" to be done for depended extension. Maybe this has something to do with symbols, I do not know.

The workaround to prevent this error is to use only PowerShell in production environment, and use only Visual Studio in development environments, and avoid mixed installation at all cost.

Other possible reasons for the error

For reference: This error can also appear if you try to export data from an unfiltered table to excel. If you have problems with excel exports and found this blog post when you googled "Sequence contains no elements", the fix for your problem is introduced for example in Cumulative Update 09 for Microsoft Dynamics 365 Business Central April'19 on-premises (Application Build 14.10.40471, Platform Build 14.10.40464)


Comment List