Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode errors :...already contains a definition for...| The call is ambiguous between the following methods or properties,

I am having these errors in VSCode -> GNU/Linux:

  • The namespace '' already contains a definition for 'GCoreT' [testc]

For this behavior I have read this,

How to fix "namespace x already contains a definition for x" error? Happened after converting to VS2010

but I can not find the solution, that works for me.


  • The call is ambiguous between the following methods or properties: 'GCoreT.mapTex(string, E[])' and 'GCoreT.mapTex(string, E[])' [testc]

  • Type 'GCoreT' already defines a member called 'mapTex' with the same parameter types [testc] void GCoreT.mapTex(string text, E[] add)

.

I think this is the most relevant simplified code.

using System;

namespace testc
{
    class Program
    {
        static void Main(string[] args)
        {
           //.. 

        }
    }
}

using System;

class GCoreT{
      ^^^------------------> he says 0


    public Ene[] GTEne (String tex, E[] ene){
    //..    
    mapTex(tex, ene); 
    ^^^------------------> he says 1
    //..
    }

    private void mapTex(String text, E[] add){
                 ^^^------------------------------> he says 2
        //..
    }
}

VSCode says:

0

The namespace '' already contains a definition for 'GCoreT' [testc]

1

The call is ambiguous between the following methods or properties: 'GCoreT.mapTex(string, E[])' and 'GCoreT.mapTex(string, E[])' [testc]

2

Type 'GCoreT' already defines a member called 'mapTex' with the same parameter types [testc] void GCoreT.mapTex(string text, E[] add)


like image 981
Angel Angel Avatar asked Apr 05 '17 16:04

Angel Angel


People also ask

How do I fix code in VS Code?

Clicking on the Code Action lightbulb or using the Quick Fix command Ctrl+. will display Quick Fixes and refactorings. If you'd just like to see refactorings without Quick Fixes, you can use the Refactor command (Ctrl+Shift+R).

How do I reset VS Code default settings?

The easiest way to reset VS Code back to the default settings is to clear your user settings.json file. You can open the settings.json file with the Preferences: Open Settings (JSON) command in the Command Palette (Ctrl+Shift+P).

Where is the settings JSON File for VS Code?

The workspace settings file is located under the . vscode folder in your project.


2 Answers

Restarting Omnisharp worked for me. Press CTRL + SHIFT + P, then select 'Restart Omnisharp' from the list

like image 57
Haroon Ibrahim Avatar answered Sep 20 '22 02:09

Haroon Ibrahim


Have you tried restarting VSCode? Could be worth a try. I have faced a similar issue and the problem seemed to magically disappear when I restarted VSCode. Seems like a bug in VSCode that when you rename namespace in certain cases it clings on to the old namespace name.

like image 37
user1314505 Avatar answered Sep 22 '22 02:09

user1314505