Tests run from VS Code Test Explorer / altool runtests crash with NullReferenceException in NavClientHandle.Dispose after Camera.IsAvailable() (Item Card, Customer Card) – pass in AL Test Tool
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- vscode
調査の方向性
Start with codeunit 50100 and run its four reproductions through altool runtests and the VS Code Test Explorer, comparing them with the AL Test Tool. Inspect the Camera.IsAvailable() path and the Item Picture and Customer Picture page behavior described in the issue. Done means all four tests complete without the NavClientHandle.Dispose NullReferenceException when no client is attached.
索引モデルが issue の本文から書いたものです。
説明
1. Describe the bug
Tests that pass in the AL Test Tool (page 130451) fail when they are run with the developer tools' test execution, i.e. the VS Code Test Explorer or altool runtests (no AL test runner). The failure is a platform exception while a page is disposed:
Unexpected CLR exception thrown.: System.NullReferenceException: Object reference not set to an instance of an object. in NavClientHandle.Dispose.
It occurs as soon as Camera.IsAvailable() has been called – directly, or indirectly by opening a card page whose picture FactBox calls it in OnOpenPage ("Item Picture" on the Item Card, "Customer Picture" on the Customer Card). As a consequence, every test that opens one of these card pages as a TestPage cannot be run from the Test Explorer or with altool runtests.
2. To Reproduce
- Create an app that depends on Microsoft apps only and add the codeunit below.
- Publish it to a BC 28.5 on-premises container that contains Microsoft apps only.
- Run codeunit 50100 with
altool runtests 50100 --server https://<container> --serverinstance BC --port 7049 --tenant default --environmenttype OnPrem --authentication UserPassword --company "CRONUS International Ltd."(or from the VS Code Test Explorer). - Run the same codeunit in the AL Test Tool (page 130451) in the web client.
codeunit 50100 "Camera Dispose Repro"
{
Subtype = Test;
TestPermissions = Disabled;
[Test]
procedure "01_Control_OpenAndClosePaymentTerms"()
var
PaymentTerms: TestPage "Payment Terms";
begin
PaymentTerms.OpenView();
PaymentTerms.Close();
end;
[Test]
procedure "02_CameraIsAvailableWithoutAnyPage"()
var
Camera: Codeunit Camera;
begin
if Camera.IsAvailable() then;
end;
[Test]
procedure "03_OpenAndCloseItemCard"()
var
ItemCard: TestPage "Item Card";
begin
ItemCard.OpenView();
ItemCard.Close();
end;
[Test]
procedure "04_OpenAndCloseCustomerCard"()
var
CustomerCard: TestPage "Customer Card";
begin
CustomerCard.OpenView();
CustomerCard.Close();
end;
}
3. Expected behavior
Same result as in the AL Test Tool: all four tests pass. For example, Camera.IsAvailable() could return false (or not create the client-side object) when no client is attached, so that the page and codeunit can be disposed.
4. Actual behavior
| Test | altool runtests (no test runner) |
AL Test Tool (page 130451) |
|---|---|---|
| 01_Control_OpenAndClosePaymentTerms | pass | pass |
| 02_CameraIsAvailableWithoutAnyPage | FAIL | pass |
| 03_OpenAndCloseItemCard | FAIL | pass |
| 04_OpenAndCloseCustomerCard | FAIL | pass |
Error of 02 (03 and 04 end in the same frames, reached via the picture FactBox of the card):
Unexpected CLR exception thrown.: System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Dynamics.Nav.Runtime.NavClientHandle.Dispose(Boolean disposing)
at Microsoft.Dynamics.Nav.Runtime.NavInteropHandleReferenceCount.Dispose()
at Microsoft.Dynamics.Nav.Runtime.NavDotNet.Clear()
at Microsoft.Dynamics.Nav.Runtime.NavDotNet.Dispose(Boolean disposing)
at Microsoft.Dynamics.Nav.Runtime.NavForm.Dispose(Boolean disposing)
at Microsoft.Dynamics.Nav.Runtime.TreeHandler.TreeObjectReferenceHandler.Dispose(Boolean disposing)
at Microsoft.Dynamics.Nav.Runtime.NavFormHandle.Dispose(Boolean disposing)
at Microsoft.Dynamics.Nav.Runtime.TreeHandler.Dispose(Boolean disposing)
at Microsoft.Dynamics.Nav.BusinessApplication.Codeunit50100._02_CameraIsAvailableWithoutAnyPage()
Analysis from the source (Base Application / System Application 28.5):
- "Item Picture"
OnOpenPage:CameraAvailable := Camera.IsAvailable();(same pattern in "Customer Picture"). - "Camera Impl."
IsAvailable()only checksGuiAllowed()– which is true in test sessions – and then calls page "Camera". - Page "Camera" holds
[RunOnClient] [WithEvents] CameraProvider: DotNet CameraProvider;.
Without an attached client there seems to be no valid client handle when this RunOnClient object is disposed. There is no way for a test to intercept before the DotNet call (OnIsCameraAvailable is raised afterwards).
5. Versions:
- AL Language: 18.0.2732683
- Visual Studio Code: 1.139.1
- Business Central: on-premises Docker container, platform 28.0.54423.0, Base Application 28.5.54151.54491 (company CRONUS International Ltd.); only Microsoft apps installed besides the repro app
- List of Visual Studio Code extensions that you have installed: not relevant for the repro above – it was run with
altool runtestsoutside VS Code. The same exception occurs for our own test codeunits in the VS Code Test Explorer. - Operating System:
- Windows
- Linux
- MacOS
Final Checklist
- Search the issue repository to ensure you are reporting a new issue (related, but different: #8233, #8254)
- Reproduce the issue after disabling all extensions except the AL Language extension (reproduced with
altool runtests, no VS Code extensions involved) - Simplify your code around the issue to better isolate the problem
- 主要言語
- PowerShell
- スター
- 889
- フォーク
- 285
- 平均マージ
- 4時間 7分
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/AL のほかの issue
-
accepted al-tools bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
難易度 4/5 1〜2日 初心者へのやさしさ 45/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 25/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Fei2411/DeepSeek-Bot#703 ·
-
enhancement help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Git-Hospital/githealthcheck#61 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 83/100
cline/mcp-marketplace#3394 ·
-
Assembly "Go to in Memory Editor" does nothing for parallel port, scratchpad and BIOS addressesオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
grumpycoders/pcsx-redux#2529 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
Pal-AI-Lab/Coopanion#538 ·
メンテナーはふだん 1 日以内に返信