Search code examples
c#.netvisual-studio-2017azure-functions

the namespace .. already contains a definition for


Why am I getting this exception, even though I only have 1 OnUnzipHttpTriggered defined?

enter image description here

I did a global search:

enter image description here

And it showed that indeed I had only 1 one of these classes defined:

enter image description here

What I have tried:

  1. rebuilt
  2. restarted visual studio
  3. checked code in and got latest

Why am I getting this exception?

Here's my VS info:

enter image description here


Solution

  • Have a look at the first result in your search. It states pretty clearly that DestinationFileNamer.cs has the namespace AlidadeUtilities.OnUnzipHttpTriggered.Extensions. That's where the problem is, because both the class and (part of) the namespace of that file are AlidadeUtilities.OnUnzipHttpTriggered.

    A class cannot have the same name as a namespace in the same namespace as where the class is.

    By the way, just a tip: anything starting with On sounds a LOT like an event handler. Please reconsider the name.

    EDIT:

    The full name of the class you're creating is this:
    AlidadeUtilities.OnUnzipHttpTriggered

    The namespace of the class DestinationFileNamer is this: AlidadeUtilities.OnUnzipHttpTriggered.Extensions

    Your problem is the fact that those two bold parts are the same.

    Solution:
    The solution would be to either rename the class OnUnzipHttpTriggered or rename the namespace AlidadeUtilities.OnUnzipHttpTriggered**.Extensions.