I am working on an ASP.NET MVC app using oData 4. Up until yesterday they project was in VB.NET. We are now finally attempting to move from VB.NET to C#. I've tried to introduce 2 controllers written in C# into the project and in both instances, receive the dreaded "No type was found that matches the controller named ***" error when attempting to access either controller.
The first one was a new controller. It looks like this:
using System.Data.Entity.Infrastructure;
using System.Net;
using System.Web.Http;
using System.Web.OData;
namespace Controllers
{
public class ORDER_LINE_SUMMARYController : ODataController
{
private Entities db = new Entities();
[EnableQuery()]
public IQueryable<ORDER_LINE_SUMMARY> GetORDER_LINE_SUMMARY()
{
return db.ORDER_LINE_SUMMARY;
}
[EnableQuery()]
public SingleResult<ORDER_LINE_SUMMARY> GetORDER_LINE_SUMMARY([FromODataUri()] decimal key)
{
return SingleResult.Create(db.ORDER_LINE_SUMMARY.Where(ORDER_LINE_SUMMARY => ORDER_LINE_SUMMARY.ID == key));
}
protected override void Dispose(bool disposing)
{
if ((disposing))
{
db.Dispose();
}
base.Dispose(disposing);
}
private bool ORDER_LINE_SUMMARYExists(decimal key)
{
return db.ORDER_LINE_SUMMARY.Count(e => e.ID == key) > 0;
}
}
}
In order to make certain that I didn't miss a step in incorporating this new controller, I also tried replacing an existing VB.NET controller with a C# controller and receive the same error. Except for the entity name, the code is essentially identical to the one above, so I'm not positing it here for brevity's sake.
One interesting note, and I think this is germane to the underlying problem. When I added the new C# controller to replace the existing VB.NET one I hadn't yet removed the VB.NET controller from the project. Obviously the class names for both are the same, however; the .NET compiler didn't error or otherwise complain about this. I suspect this issue may be related to attempting to mix C# and VB.NET within the same assembly due to this.
Any suggestions or ideas would be greatly appreciated. TIA.