AL icon indicating copy to clipboard operation
AL copied to clipboard

vLatest (https://bcinsider.azureedge.net/sandbox/21.0.41005.0/w1) issue with AL0157

Open cvale opened this issue 4 years ago • 9 comments

Hi guys. We're having strange issue when compiling our product against vLatest (Using artifactUrl https://bcinsider.azureedge.net/sandbox/21.0.41005.0/w1). When using variables of type ControlAddin inside another objects (in this case CodeUnits), we're getting error AL0157: 'XY' is not a valid variable type (xy being ControlAddin type).

Is this a bug in vLatest? All previous versions since BC17 work without issues.

Compiler version: AL Compiler version 10.0.9.38389

Code sample:

codeunit 50000 "Logo Mgt."
{
    Access = Internal;

    var
        ResizeImage: ControlAddIn "ResizeImage"; //fails on this line. ResizeImage defined as controladdin ResizeImage

....

Thanks.

cvale avatar May 25 '22 09:05 cvale

We previously planned to disallow this, because it was breaking at runtime in some instances. But due to in influx of issues regarding this usage of ControlAddIns, we have decided to revert this change.

EmilDamsbo avatar May 25 '22 13:05 EmilDamsbo

The fix for this issue has been checked in to the master branch. It will be available in the bcinsider.azurecr.io/bcsandbox-master Docker image starting from platform build number 41482 and VS Code Extension Version 10.0.632807.

If you don’t have access to these images you need to become part of the Ready2Go program: aka.ms/readytogo

For more details on code branches and docker images please read: https://blogs.msdn.microsoft.com/nav/2018/05/03/al-developer-previews-multiple-releases-and-github/ https://freddysblog.com/2020/06/25/working-with-artifacts/

JesperSchulz avatar Jun 02 '22 12:06 JesperSchulz

We have Codeunits that

  • have global variables of ControlAddIn type,
  • copy them from Pages' ControlAddIns passed to an initialisation function in the Codeunit, and
  • do stuff with them afterwards in that Codeunit.

Thus I guess that

  • ControlAddIn is a reference type
  • whatever we were doing with it is OK, maybe because we reassign the global reference to point at a valid ControlAddIn instantiated by the Page, rather than the one instantiated (or not?) by the Codeunit

So I would think then that

  • our existing code will work again in the next version?
  • to avoid doing this, in case it again becomes an error later, we will have to pass the ControlAddIns to all functions in such Codeunits that need them, instead of 'storing' them as a global in the Codeunit... which seems a best practice anyway.

Do I understand correctly? Thanks!

dzzzb avatar Jun 14 '22 16:06 dzzzb

The change was wrong is reverted. All existing code should work again on the latest insider builds. If not let us know.

esbenk avatar Jun 14 '22 17:06 esbenk

Hi @esbenk, @JesperSchulz Can you please let us know in which version this is/was expected to be fixed? I just tested it with the current SaaS version and still get the error.

Version in which we had the initial problem on friday: Version: GB Business Central 20.2 (Platform 20.0.41086.41862 Application 20.2.41144.41547

Version I tested with just now: Version: GB Business Central 20.2 (Platform 20.0.41086.42065 + Application 20.2.41144.41547)

In both cases the installation from AppSource fails with the following error:

Deployment failed. Errors: App ID : 5716c909-a743-461e-ac12-d99759152986 Message : { Extension compilation failed
src_Base_Module/NETVPSControlAddInShell.Codeunit.al(46,15): error AL0157: 'NetronicVSControlAddIn' is not a valid variable type } - Job Id : 5d74f919-06cf-4d05-bc42-53eb830ab9b6

The same applies to all our other extensions in appsource. This currently renders our complete product line (3 extensions) uninstallable/unusable in version BCv20.2

Looking forward to your feedback. Thank you very much.

SHermann73 avatar Jun 15 '22 12:06 SHermann73

It is on its way to 20.2 as well.

esbenk avatar Jun 15 '22 13:06 esbenk

Our pipeline is also failing with the same error message on BC 20.2.41144.42196. Tested the same code on older version (20.1.39764.41791) it ran fine without an error.

error AL0157: 'CustomControlAddin' is not a valid variable type

carlosyuwono avatar Jun 15 '22 14:06 carlosyuwono

Hello everyone,

Heads up! The hotfix is rolling out right now. The updated version is Platform 20.0.41086.42208.

Best, Nikolay

nndobrev avatar Jun 15 '22 14:06 nndobrev

Hi @nndobrev I can confirm that the mentioned version was rolled out to our environment today and I could successfully install all our extensions again.

SHermann73 avatar Jun 19 '22 13:06 SHermann73