I have an extension method like
public static class Extension
{
public static string GetTLD(this string str)
{
var host = new System.Uri(str).Host;
int index = host.LastIndexOf('.'), last = 3;
while (index >= last - 3)
{
last = index;
index = host.LastIndexOf('.', last - 1);
}
var domain = host.Substring(index + 1);
return domain;
}
}
And I am calling this like
string domain = "." + _url.GetTLD();
I am getting no error at building and clean build.
But I am getting compilation error
at run time error saying
The call is ambiguous between the following methods or properties: 'myIGNOU.Extension.GetTLD(string)' and 'myIGNOU.Extension.GetTLD(string)'
I swear that I don't have this extension method placed any where else too in the project. Why I am getting this error only at run time..?
But if I delete this method then I am getting error at build time not not at run time. Everything works fine without the code of this method.
I had the same problem but for me it solved the problem to remove the own project from the project references. Resharper accidentally added a reference to the compiled binary of the same project. That way I had the same extension class 2 times within my project. During building it couldn't distinguish between the source-version or the binary-version of the extension class.
So basically: Check your project references if it contains a reference to itself.
Answer provided by @shashwat is also a case.