Dynamics 365 Business Central: The namespace ‘Microsoft’ is reserved and must be renamed (Uploading Extension error)

Dynamics 365 Business Central

Hi, Readers.
Today I would like to share an error handling of Business Central. I’ve received this question more than once recently. This is an error about uploading PTE in a production environment.

Version: W1 23.5 (Platform 23.0.17596.0 + Application 23.5.16502.16589)

Let’s look at a simple example.

Error: From the error message, this is a namespace related error.

Package validation failed due to the following error(s): test.al (1,11) – Error PTE0021: The namespace ‘Microsoft’ is reserved and must be renamed. – Job Id : 471a9a5f-fff4-4f9f-80e7-cb1fc010ef44

In Business Central 2023 wave 2 (BC23), AL for Business Central now supports namespaces. More details: Business Central 2023 wave 2 (BC23): Segment AL code and reduce naming conflicts with namespaces (Namespaces in AL)
This is also used in all standard objects.

PS: In computing, a namespace is a set of signs (names) that are used to identify and refer to objects of various kinds. A namespace ensures that all of a given set of objects have unique names so that they can be easily identified. More details: Namespace

First of all, this error does not occur in the Sandbox environment and cannot be debugged.
The reason for this is also very simple. When you copy a standard object and then create your own customization, you may copy all the code completely, including the namespace. For example, as of now, we cannot extend the API page, so if you copy the standard code, you may copy the following line.
More details: Dynamics 365 Business Central: Can we extend standard APIs? – Download Standard Source Code for APIs

namespace Microsoft.API.V2;

This does not cause errors during compilation. As mentioned in the error message, the namespace ‘Microsoft’ is reserved and must be renamed. So you just need to change Microsoft to any other character, and it’s fine.
For example,

namespace ZY.API.V2;

Great, I hope it will give you some help when you encounter this problem.

PS:
1. Dynamics 365 Business Central: Specify namespaces for multiple objects at a time (Structuring namespaces in AL)

2. What’s new: Business Central developer tools (2023 release wave 2)

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL