简体   繁体   中英

Immediate window cannot find class in namespace

I have a method which is located like this in my code

namespace DMR
{
    public static class MyClass
    {
        public static void MyMethod()
        {
            // Do stuff here
            // (...)
        }
    }
}

I have tried calling it from the Immediate Window with the following command:

DMR.MyClass.MyMethod();

Which returns a namespace error:

The type or namespace name 'MyClass' does not exist in the namespace 'ProjectName.DMR'

I have also tried adding the project name in front of the namespace in the call, but that doesn't change anything. I should perhaps note that the namespace is different from the folder name, since the folder name was changed after creation (without changing the namespace), I do not know, if this has any effect.

What am I doing wrong?

I decided to change the namespace to match the folder name. This made it work. I still don't know why the folder name of the file and the namespace has to be the same, so if anyone has an explanation for that, it would be nice.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM