AL icon indicating copy to clipboard operation
AL copied to clipboard

altpgen throws error in version 8.2.550913

Open deadmouse opened this issue 5 years ago • 11 comments

1. Describe the bug Using altpgen.exe throws error in AL version 8.2.550913 but not in version 8.2.545335.

2. To Reproduce Steps to reproduce the behavior:

  1. Open CMD
  2. Go to C:\Users\USERNAME.vscode\extensions\ms-dynamics-smb.al-8.2.550913\bin
  3. Paste: .\altpgen -project:"C:\Users\USERNAME\Documents\Developments\CLIENT\app" -packagecachepath:"C:\Users\USERNAME\Documents\Developments\CLIENT\app.alpackages" -serviceuri:"https://CLIENT.crm4.dynamics.com/" -entities:whatever_entities,team,systemuser -baseid:57600 -tabletype:CDS

3. Expected behavior Download table .al files

4. Actual behavior Console throws this error:

muser -baseid:57600 -tabletype:CDS Microsoft (R) AL Table Proxy Generator version 8.2.8.26641 Copyright (C) Microsoft Corporation. All rights reserved

Authenticating Dataverse using ServiceUri=https://CLIENT.crm4.dynamics.com/ System.IO.FileLoadException: No se puede cargar el archivo o ensamblado 'Microsoft.Identity.Client, Version=4.7.1.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae' ni una de sus dependencias. La definición del manifiesto del ensamblado no coincide con la referencia al ensamblado. (Excepción de HRESULT: 0x80131040) Nombre de archivo: 'Microsoft.Identity.Client, Version=4.7.1.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae' en Microsoft.Dynamics.Nav.TableProxyGenerator.AzureADAuthenticationHelper..ctor(String clientId, String authority, String redirectUri, CompilerTextWriter compilerTextWriter) en Microsoft.Dynamics.Nav.TableProxyGenerator.TableProxyGeneratorTool.RunCore(CompilerTextWriter consoleOutput, ErrorLogger errorLogger, CancellationToken cancellationToken) en D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.TableProxyGenerator\TableProxyGeneratorTool.cs:línea 36 en Microsoft.Dynamics.Nav.CodeAnalysis.CompilationDependentTool.Run(CompilerTextWriter consoleOutput, ErrorLogger errorLogger, CancellationToken cancellationToken) en D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.TableProxyGenerator\CompilationDependentTool.cs:línea 125 en Microsoft.Dynamics.Nav.CodeAnalysis.CompilationDependentTool.Run(CompilerTextWriter consoleOutput, CancellationToken cancellationToken) en D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.TableProxyGenerator\CompilationDependentTool.cs:línea 77 en Microsoft.Dynamics.Nav.TableProxyGenerator.TableProxyGeneratorCommandLineTool.Run(String clientDirectory, String baseDirectory, String[] args)

AVS: El registro del enlace de ensamblado está desactivado. Para habilitar el registro de errores del enlace de ensamblado, establezca el valor de Registro [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) como 1. Nota: existe una disminución del rendimiento asociada registro de errores del enlace de ensamblado. Para desactivar esta característica, elimine el valor de Registro [HKLM\Software\Microsoft\Fusion!EnableLog].

5. Versions:

  • AL Language: 8.2.550913
  • Visual Studio Code: 1.62.3
  • Business Central: Not needed
  • List of Visual Studio Code extensions that you have installed: AL CodeActions, AL Language, Argutec Azure Repos, ATDD.TestScriptor, AZ AL Dev Tools/AL Code Outline, Create GUID, Explorer Exclude, Git Graph, Gitlens - Git supercharged, PowerShell, Todo Tree, waldo's CRS AL Language Extension.

Final Checklist

Please remember to do the following:

  • [X] Search the issue repository to ensure you are reporting a new issue

  • [X] Reproduce the issue after disabling all extensions except the AL Language extension

  • [X] Simplify your code around the issue to better isolate the problem

deadmouse avatar Dec 01 '21 10:12 deadmouse

I have got exact the same isseu with version ms-dynamics-smb.al-8.2.550913 with version ms-dynamics-smb.al-8.2.545335 it all works perfect.

Bertverbeek4PS avatar Dec 03 '21 14:12 Bertverbeek4PS

New version is coming soon with this fix :)

nndobrev avatar Dec 03 '21 17:12 nndobrev

We have this problem as well, what is the exact release date of dataverse connection bug free visual studio extension? ASAP please.

rgx91 avatar Dec 07 '21 13:12 rgx91

Version 8.2.552672 that is currently the latest available in VSC marketplace should have fixed the issue, please check.

nndobrev avatar Dec 07 '21 13:12 nndobrev

Closing the issue, please reopen if you think the problem is still present on the latest version.

nndobrev avatar Dec 07 '21 13:12 nndobrev

Sorry, this still seems to be a problem.

As you can see, AL extension version is 8.2.552672. The login dialogue comes up, enter admin user name, enter password, account requires MFA so ask for an SMS, SMS arrives, key in the code supplied and it fails.

PS C:\users\MyName.vscode\extensions\ms-dynamics-smb.al-8.2.552672\bin> .\altpgen.exe -project:"D:\Development\AL\ProjectName" -packagecachepath:"D:\Development\AL\ProjectName.alpackages" -serviceuri:"https://mycustomer-uat.crm11.dynamics.com" -entities:account,location -baseid:60000 -tabletype:CRM Microsoft (R) AL Table Proxy Generator version 8.2.8.28400 Copyright (C) Microsoft Corporation. All rights reserved

Authenticating Dataverse using ServiceUri=https://mycustomer-uat.crm11.dynamics.com error CDS0001: Error connecting to Dataverse. Microsoft.Dynamics.Nav.Xrm.Common.XrmException: Could not load file or assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Server stack trace:

Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Microsoft.Dynamics.Nav.Xrm.Common.IXrmService.Connect(String serviceUri, String token) at Microsoft.Dynamics.Nav.TableProxyGenerator.XrmMetadataService.CreateXmlMetadataService(String serviceUri, String token) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.TableProxyGenerator\Xrm\XrmMetadataService.cs:line 67 at Microsoft.Dynamics.Nav.TableProxyGenerator.TableProxyGeneratorTool.CreateXrmMetadataService(IList`1 diagnostics, String token) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.TableProxyGenerator\TableProxyGeneratorTool.cs:line 84

Tried in Powershell 5 & 7, tried installing PS Azure AD module, ADAL.PS module, even tried dropping the correct DLL in the bin folder so that it is there to be found. Checked .NET framework is greater than 4.8 (which is what the altpgen.exe.config requires). All failed.

Tried it on a different customer that doesn't require MFA and which had worked on a previous version of altpgen and that failed the same way.

I've got a deadline to meet so I'm going to try handcrafting the tables, but please advise soonest. Thanks.

MajorBarf avatar Dec 08 '21 17:12 MajorBarf

I am getting the same error as MajorBarf on AL extension version v8.2.552672

Microsoft (R) AL Table Proxy Generator version 8.2.8.28400 Copyright (C) Microsoft Corporation. All rights reserved

Authenticating Dataverse using ServiceUri=https://XXXXX.crm3.dynamics.com/ error CDS0001: Error connecting to Dataverse. Microsoft.Dynamics.Nav.Xrm.Common.XrmException: Could not load file or assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=5.2.7.0, Culture=neutral, PublicKeyToken=XXXXXXXXX' or one of its dependencies. The system cannot find the file specified.

Server stack trace:

Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Microsoft.Dynamics.Nav.Xrm.Common.IXrmService.Connect(String serviceUri, String token) at Microsoft.Dynamics.Nav.TableProxyGenerator.XrmMetadataService.CreateXmlMetadataService(String serviceUri, String token) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.TableProxyGenerator\Xrm\XrmMetadataService.cs:line 67 at Microsoft.Dynamics.Nav.TableProxyGenerator.TableProxyGeneratorTool.CreateXrmMetadataService(IList`1 diagnostics, String token) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.TableProxyGenerator\TableProxyGeneratorTool.cs:line 84

L-PDS avatar Dec 08 '21 19:12 L-PDS

Indeed with version 8.2.552672 you have above problems when there is logged in.

Bertverbeek4PS avatar Dec 08 '21 19:12 Bertverbeek4PS

I managed to get this working by switching to an older version. Here's what I did:

  1. Open the AL Language extension in VS Code. Click the down arrow next to uninstall, click install another version, pick version 7.1.453917. Reboot the extension.
  2. In app.json, remove the "resourceExposurePolicy" section and set the runtime to 7.0. rebuild the project.
  3. Run the altpgen.exe in Powershell

L-PDS avatar Dec 08 '21 21:12 L-PDS

Thanks L-PDS, that works. It is rubbish that it has to be like that, but it works. :)

So in AL extension 7.1.453917 the altpgen.exe.config refers to Microsoft.IdentityModel.Clients.ActiveDirectory v3.13 and the bin folder contains that DLL, but it is v5.2.7.0. Then in AL extension 8.2.552672 the altpgen.exe.config refers to Microsoft.IdentityModel.Clients.ActiveDirectory v5.2.7.0 but that DLL is missing from the bin folder. However, it does have Microsoft.Identity.Client which allegedly is a newer replacement (according to https://www.nuget.org/packages/Microsoft.IdentityModel.Clients.ActiveDirectory/)

I did try getting the correct DLL & version, but dropping it into the bin folder didn't fix the problem. I think I restarted VS Code afterwards but can't be sure because I did so much trying to fix this yesterday.

MajorBarf avatar Dec 09 '21 11:12 MajorBarf

I have created isseu https://github.com/microsoft/AL/issues/6866 for this isseu. So hopefully you don't need the work around.

Bertverbeek4PS avatar Dec 09 '21 14:12 Bertverbeek4PS