skip to Main Content

I’m trying to get an older project to build. The application had two versions and the "v2" version is in a subfolder of the parent.

The namespace for the parent is BackOfficeAPI.

The namespace for the sub-application is BackOfficeAPI2.

If I remove the v2 folder completely, the application builds. If I add it back in, everything in that folder tosses errors – every class, every widget on every page.

I’ve verified that every file (class, web form) in the v2 folder specifies namespace BackOfficeAPI2 and I’ve checked that everything in the parent specifies BackOfficeAPI.

Example top of a class file in v2 application:

namespace BackOfficeAPI2
{
    class SqlServer : DataObject

(rest of file omitted)

Error: The type or namespace "DataObject" could not be found

However..

namespace BackOfficeAPI2 {
    class DataObject

It does exist. This would seem to be a namespace conflict between the child and parent applications but I cannot find it.

This application used to run fine like this and I’m not aware of any changes to the source.

If I try, above:

namespace BackOfficeAPI2 {
    class SqlServer : BackOfficeAPI2.DataObject

At the point of keying the . after BackOfficeAPI2 the only thing the intellisense can find is the source file itself containing the code I’m editing, and nothing else in BackOfficeAPI2. It cannot see "BackOfficeAPI2.DataObject".

What do I need to do to persuade Visual Studio 2017 to resolve the BackOfficeAPI2 namespace and build the project?

2

Answers


  1. Chosen as BEST ANSWER

    I wasn't able to get this to build in Visual Studio. For whatever reason it will not build that second namespace.

    However, I added IIS Manager to Windows 11, then opened that and pointed the default website at the project top-level folder. I then added an "Application" folder using the tree on the left, and pointed that at the sub-folder.

    While it won't build in Visual Studio, it executes perfectly via IIS - both the base site loads and runs, and then using the sub-folder Url configured as above, that also loads and runs.

    Not ideal for ongoing development, but this is an older project that just needs a few tweaks, which on this occasion can be done using local IIS as the debugger bypassing Visual Studio altogether.


  2. Refer to class-cannot-find-another-class-in-the-same-namespace
    Ensure that the files in the v2 folder have their Build Action correctly set to Compile:

    • In Solution Explorer, select the files in the v2 folder, right-click,
      and choose Properties.
    • In the Properties window, ensure that the Build Action is set to
      Compile.

    Remember close VS2017 down, reopening, Clean and Rebuild the project after setting Build Action

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search