.NET Daily

‘MethodName’ is an ambiguous reference between ‘namespace1’ and ‘namespace2’

Introduction

Darius

Darius

Darius Dumitrescu is a creative Senior CMS Consultant with in depth .NET knowledge, focused on Web Development and Architecture Design.


LATEST POSTS

How to solve: An expression tree may not contain a dynamic operation – ASP.NET Core 06th July, 2019

How to use DbContext Scaffold to add only selected tables – ASP.NET Core 01st July, 2019

Common .NET Exceptions

‘MethodName’ is an ambiguous reference between ‘namespace1’ and ‘namespace2’

Posted on .

Error: ‘MethodName’ is an ambiguous reference between ‘namespace1’ and ‘namespace2’.

Scenario1: Well, this is simple, you have the same method name in both ‘namespace1’ and ‘namespace2’.

Cause of Scenario 1: When you add namespace references that contains the same method name you use in your code, .NET don’t know from where to take the good method and throw the error above.

Resolution of Scenario 1: You have two possibilities:

  • You remove one of the namespaces that has the same method;
  • You add an alias to one of your namespaces if you must keep both of them and then you add in front of the conflicted method the namespace alias. Ex:
using myNamespace = System.Namespace1;
Darius

Darius

Darius Dumitrescu is a creative Senior CMS Consultant with in depth .NET knowledge, focused on Web Development and Architecture Design.

There are no comments.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

View Comments (0) ...
Navigation