BLOG

An application object of type x is already declared

Yes, it’s a Visual Studio Code error, and it has been bugging me for days. No, that’s too mild. It has been driving me nuts! Of course, the message is clear, and you’d think the solution is simple. The only problem is: The application object has not already been declared. There’s only one.

The Problem

A quick explanation of what’s happening:

  1. I start a new project (usually through AL: Go!), fix the launch.json and download symbols.
  2. Develop away… my smallest project has two codeunits, two page extensions and one table extension.
  3. Everything is fine (No “Problems”) right up until I press F5 (Start Debugging) for the first time.
  4. After testing whatever it is I want to test, I continue developing and suddenly the messages start popping up. In this case, I have 5 of them:
Tab-Ext60500.TabExtObject.al
-- An application object of type 'TableExtension' with ID '60500' is already declared AL(AL0264) [1,16]
-- An application object of type 'TableExtension' with name 'TabExtObject' is already declared AL(AL0197) [1,22]
-- The extension object 'TabExtObject' cannot be declared. Another extension for target 'Item' or the target itself is already declared in this module. AL[0334] [1,22]
-- A field with name 'TabExtObjectField1' is already defined AL(AL0205) [6,21]
-- A field with name 'TabExtObjectField2' is already defined AL(AL0205) [17,21]
  1. After seeing these errors, just accept, modify whatever you need to modify, press F5 (Start Debugging).
  2. You’d expect the compiler to also crash on problems like the above, but it doesn’t. It compiles and runs flawlessly.

On this project, I can more or less handle this issue. It’s just 5 errors and if something shows up that I do want to see, I’ll see it. On one of our other projects I was developing on, I have 1146 problems. If this flips to 1147, or 1148, I’ll have no clue where to look. Annoying, to put it mildly.

The Solution

So, after visiting a Dynamics event last evening (well.. a few hours ago), I had some new motivation to figure out what’s the cause of this, and started trying to reproduce the issue from a brand new laptop, and with the “Hello, World!” app. This clean machine caused me to find it, because I suddenly started developing from the local Documents folder.

It’s dead simple: UNC paths!

To prevent data loss (or worse) we have a policy to not store anything on our laptops but keep everything on “the network”. Also the source code. As a result, our projects are all in \\server.domain\Dynamics Tailor BV\projects\projectname\

Visual Studio Code seems to be okay with this, but it clearly isn’t. I just solved the issue on my own machine by simply mapping the network drive to a drive letter and it’s working like a charm.

Well… just one thing left to say:

Other Posts