Working in a C# WebApp project which I've inherited. I have a couple function definitions as so...
public static DataTable ExecuteDT(this AppDBContext target, string sql, int timeoutSeconds = defaultTimeoutSeconds) {
DbCommand cmd = target.Database.Connection.CreateCommand();
cmd.CommandText = sql;
cmd.CommandType = System.Data.CommandType.Text;
if (timeoutSeconds != defaultTimeoutSeconds) cmd.CommandTimeout = timeoutSeconds;
DataTable rv = new DataTable();
rv.Load(cmd.ExecuteReader());
return rv.Copy();
}
public static object ExecuteDR(this AppDBContext target, string sql, int timeoutSeconds = defaultTimeoutSeconds) {
DataTable dt = target.ExecuteDT(sql, timeoutSeconds);
return (ReferenceEquals(dt, null) || dt.Rows.Count == 0) ? null : dt.Rows[0];
}
When I do a Build on the application, it compiles fine with zero errors.
However, when I try to run the website (using F5), it launches in my browser, and then comes up with a compile error:
Compiler Error Message: CS0121: The call is ambiguous between the following methods or properties:
'ConstructionLoan.WebFormsApp.DataExtensions.ExecuteDT(ConstructionLoan.Domain.Data.AppDBContext, string, int)' and
'ConstructionLoan.WebFormsApp.DataExtensions.ExecuteDT(ConstructionLoan.Domain.Data.AppDBContext, string, int)'
Source Error:
Line 34:
Line 35: public static object ExecuteDR(this AppDBContext target, string sql, int timeoutSeconds = defaultTimeoutSeconds) {
Line 36: DataTable dt = target.ExecuteDT(sql, timeoutSeconds);
Line 37: return (ReferenceEquals(dt, null) || dt.Rows.Count == 0) ? null : dt.Rows[0];
Line 38: }
Source File: c:\Users\myuser\Source\Workspaces\ourclient\src\Web\Main\ConstructionLoan.WebFormsApp\App_Code\DataExtensions.cs Line: 36
It is complaining about the same exact function being ambiguous with itself. I have done a search through all of the source code, and this is the one and only declaration of this function, so I am really scratching my head as to what the compiler is getting confused over.
The only question I found on Google that was similar to this was someone who's project had somehow wound up referencing itself. I double-checked to make sure that this project is not referencing itself, and it is not.
I've also tried doing a Clean and Rebuild of the project.
For whatever reason, this project compiles fine in the IDE, but when attempting to run it in the browser it craps out.
I'm working in VS 2015, and targeting the 4.5.2 version of the Framework.