microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
744 stars 245 forks source link

altpgen throws error in version 8.2.550913 #6853

Closed deadmouse closed 2 years ago

deadmouse commented 2 years ago

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:

Final Checklist

Please remember to do the following:

Bertverbeek4PS commented 2 years ago

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.

nndobrev commented 2 years ago

New version is coming soon with this fix :)

rgx91 commented 2 years ago

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

nndobrev commented 2 years ago

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

nndobrev commented 2 years ago

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

MajorBarf commented 2 years ago

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.

L-PDS commented 2 years ago

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

Bertverbeek4PS commented 2 years ago

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

L-PDS commented 2 years ago

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
MajorBarf commented 2 years ago

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.

Bertverbeek4PS commented 2 years ago

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