web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

An Application object of type 'Codeunit' with name XXX is already declared

(1) ShareShare
ReportReport
Posted on by 71

Hello Everyone !

Right now i'm moving my company's code from Dynamics nav 2018 to Business Central 16.

I'm working with VS Code, so that means a brand new environment to discover.
Right now, i'm having troubles with one of our most used Codeunits.

pastedimage1596699436234v1.png

VS Code is telling me that "An application object of type Codeunit with name Toolbox is already declared'. Except it's not.

I've checked, neither the name nor the id are used anywhere in my code.

In some other codeunits, i still can declare my Toolbox codeunit but in some others i simply can't. It causes a lot of problems in my code, since i'm getting everywhere errors about procedures being non existant in my toolbox codeunit (except they are).

I've searched for similar issues, learned it could be due to UNC paths but what my coworker and i tried didn't seem to do the trick.

Has anyone else experienced this and would be willing to share their solution ? 

Thanks in advance

I have the same question (0)
  • Dan Kinsella Profile Picture
    468 on at

    Hi Valentine,

    Is Primus-wine the extension you're developing?

    It might just be the AL extension getting in a mess.. this does happen often on larger projects and can usually be resolved by shutting down VS Code and reopening it.

    You'll want to look into name prefixing of your objects to stop name conflicts with other extensions in either case: docs.microsoft.com/.../apptest-prefix-suffix

  • Valentine Motin Profile Picture
    71 on at

    Hi Dan,

    I've already tried to restart VS Code but unfortunately this didn't change anything.

    Primus Wine is the extendion i'm developping, it's a really large project that has existed since before Nav 2013, and moved from version to version but my codeunit doesnt seem to be conflicting with another extension. When i try to rename my object, it seems to solve the issue so i dont know where the issue can come from.

    I'll talk to my team about the prefixing, thanks for the insight !

  • Suggested answer
    Dan Kinsella Profile Picture
    468 on at

    Try using the search tool from the activity pane on the left on that object name, perhaps you have it declared in another file somewhere in your project workspace.

    When you choose a pre/post fix, I'd recommend the CRS extension (available from the VS Code marketplace) for automatically updating the prefix and renaming al files to MS standards. Really helps to keep everyone working constantly.

  • Valentine Motin Profile Picture
    71 on at

    I don't see anything that could look like a second declaration. However, there is something i think is weird : whenever i go to any object that uses my Toolbox codeunit at some point and click on "Go to definition", sometimes it will send me on my Toolbox codeunit - as expected - but sometimes it will send me in the local variables of a procedure from a codeunit that has absolutely nothing to do with the first object nor with the Toolbox codeunit. It's not random because it's always the same procedure in the same codeunit, but i don't see anything wrong with my codeunit declaration.

  • Suggested answer
    Yuri Mishin Profile Picture
    20 on at

    I have got the same problem today.

    That's obviously not a problem of the compiler, the app can be compiled and published without an error.

    Solution (worked for me):

    - disable Visual Studio Code extension "AL Language".

    - enable Visual Studio Code extension "AL Language".

    - wait till it loads and parses the source code.

  • Suggested answer
    JP-10061045-0 Profile Picture
    10 on at
    For me none of the suggested solutions worked. What helped me was the answer in this blog https://www.365cycle.nl/dynamics/an-application-object-of-type-x-is-already-declared/
     
    Solution was to map the network path that the project resides on to a drive letter.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,143

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,694 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,067 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans