Error CS012 The call is ambiguous between the following methods or properties

In this azure tutorial, we will discuss how to fix the Error CS012 The call is ambiguous between the following methods or properties. This error I got after executing the Azure Function Code to interact with the SharePoint From Azure Function to delete a SharePoint list using the Visual Studio 2019.

Error CS012 The call is ambiguous between the following methods or properties

Recently, I was trying to write an Azure Function code to interact with SharePoint to delete a SharePoint List using the Visual Studio 2019 IDE. I got this error.

Below was my Azure Function code

[FunctionName("NewFunction")]
        public static async Task<HttpResponseMessage> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage request,
            ILogger log)
        {

            string site = "https://tsinfo.sharepoint.com/sites/SPFx/";
            string userName = "ASE@tsinfo.onmicrosoft.com";
            string password = "#####@12345";

            // parse query parameter  
            string listtitle = request.GetQueryNameValuePairs()
                .FirstOrDefault(q => string.Compare(q.Key, "title", true) == 0)
                .Value;


            System.Security.SecureString secureString = new System.Security.SecureString();
            foreach (char ch in password)
            {
                secureString.AppendChar(ch);
            }

            SharePointOnlineCredentials creds = new SharePointOnlineCredentials(userName, secureString);

            using (var ctx = new ClientContext(site))
            {
                ctx.Credentials = creds;
                List lst = ctx.Web.Lists.GetByTitle(listtitle);
                lst.DeleteObject();
                ctx.ExecuteQuery();
                return lst == null
                ? request.CreateResponse(HttpStatusCode.BadRequest, "Error retreiveing the list")
                : request.CreateResponse(HttpStatusCode.OK, "ListDeleted successfully " + listtitle);
            }
            return null;
        }
    }

When i started executing the code, I got the below error

Error CS012 The call is ambiguous between the following methods or properties

Below was the exact error message, that I got,

Error CS012 The call is ambiguous between the following methods or properties: ‘System.Net.Http.HttpRequestMessageExtensions.CreateResponse(System.Net.Http.HttpRequestMessage, System.Net.HttpStatusCode, T)’ and ‘System.Net.Http.HttpRequestMessageExtensions.CreateResponse(System.Net.Http.HttpRequestMessage, System.Net.HttpStatusCode, T)’ deletesplistvs C:\Users\Bijay\source\repos\deletesplistvs\deletesplistvs\Function1.cs

You can see it here

Error CS012 The call is ambiguous between the following methods or properties
The call is ambiguous between the following methods or properties

Error CS012 The call is ambiguous between the following methods or properties [Solved]

To fix this issue, I have uninstalled the following Nuget package which i have installed earlier that i don’t need now.

Microsoft.AspNetCore.Mvc.WebApiCompatShim

You need to right click on the Project and click on the Manage NuGet Packages.

Ambiguous between methods or properties in C# .NET
‘The call is ambiguous between the following methods or properties’

You can find out the above nuget package and click on the Uninstall button

The call is ambiguous between the following methods or properties
C# Error: The call is ambiguous between the following methods or properties.

Now click on the I Accept button to accept the License

Error CS012 The call is ambiguous between the following methods or properties: 'System.Net.Http.HttpRequestMessageExtensions.CreateResponse
the call is ambiguous between the following methods

After that you will not get any error

The call is ambiguous between the following methods in C#
Error The call is ambiguous between the following methods or properties

Basically, try uninstalling the unnecessary NuGet packages that you might have installed and you are not actually using them.

This is how you can fix the Error CS012 The call is ambiguous between the following methods or properties

System.Linq: The call is ambiguous between the following methods or properties [Solved]

In one of my C# Project, I was referring to the System.Linq namespace from a local path. When I was trying to compile the C# Project, I got the error ” The call is ambiguous between the following methods or properties“.

One point to note down here is, Don’t refer to the System.Linq namespace explicitly and always uses the namespace version from the GAC instead of referring to the namespace from the local bin.

You may also like following the below articles

Wrapping Up

Well, in this article, we discussed, how to fix the Error CS012 The call is ambiguous between the following methods or properties, System.Linq: The call is ambiguous between the following methods or properties, The call is ambiguous between the following methods in C#. Hope it will help you to fix your issue as well !!!