-
Notifications
You must be signed in to change notification settings - Fork 122
"Multiple actions matched" for controller in area on Mono #391
Comments
Thanks for reporting this. |
@rynowak Where is that code located? I could try to debug it and see why it's not working properly. For what it's worth, I'm only seeing this for one controller in the app. Other controllers are working fine 😕 |
Now that's really strange.. Code is here, note that we fixed a bug in this code in |
So this does look like a Mono bug with However, even considering that... Why would the route even be matching As for the bug, I made a small console app to test: class Foo : IDisposable
{
public void Dispose() => Dispose(disposing: true);
protected virtual void Dispose(bool disposing) {}
}
class Bar : Foo { }
class Foo2 : Microsoft.AspNetCore.Mvc.Controller { }
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Regular class:");
Test(typeof(Foo));
Console.WriteLine();
Console.WriteLine("Inheritance:");
Test(typeof(Bar));
Console.WriteLine();
Console.WriteLine("Controller:");
Test(typeof(Foo2));
}
static void Test(Type type)
{
var methodInfo = type.GetMethod("Dispose");
var baseMethodInfo = methodInfo.GetBaseDefinition();
var declaringTypeInfo = baseMethodInfo.DeclaringType.GetTypeInfo();
var firstTargetMethod = declaringTypeInfo.GetRuntimeInterfaceMap(typeof(IDisposable)).TargetMethods[0];
Console.WriteLine("IsAssignableFrom: {0}", typeof(IDisposable).GetTypeInfo().IsAssignableFrom(declaringTypeInfo));
Console.WriteLine("TargetMethod is equal (==): {0}", firstTargetMethod == baseMethodInfo);
Console.WriteLine("TargetMethod is equal (Equals): {0}", firstTargetMethod.Equals(baseMethodInfo));
Console.WriteLine("baseMethodInfo: {0} attribs={1}", baseMethodInfo, baseMethodInfo.Attributes);
Console.WriteLine("targetMethod: {0} attribs={1}", firstTargetMethod, firstTargetMethod.Attributes);
}
} The output when running it on Windows is what you'd expect:
However, the output on Mono is odd and
Mono bug reported: https://bugzilla.xamarin.com/show_bug.cgi?id=53690 |
As a temporary workaround, I'm overriding public class BugfixApplicationModelProvider : DefaultApplicationModelProvider
{
public BugfixApplicationModelProvider(IOptions<MvcOptions> mvcOptionsAccessor) : base(mvcOptionsAccessor) {}
protected override bool IsAction(TypeInfo typeInfo, MethodInfo methodInfo)
{
return methodInfo.Name != "Dispose" && base.IsAction(typeInfo, methodInfo);
}
} And replacing the standard implementation with mine:
I don't have any actions named "Dispose", so this is a fine workaround. 😃 |
Hmm so Mono appears to have unusual behavior here, but perhaps MVC is doing something weird as well, which causes the Mono behavior difference to be problematic? @rynowak - do you feel it's worth looking into why MVC is doing why it's doing, or consider this a Mono bug and close this issue? |
This has been fixed in Mono: https://bugzilla.xamarin.com/show_bug.cgi?id=53690. Let's just close this out. |
Awesome. thanks |
After upgrading from .NET Core 1.0 to 1.1.1, I'm hitting this error on Mono:
However, the exact same controller works fine on .NET Framework 4.5
The controller does not even have a
Dispose
method so I have no idea why the routing is picking it up :/Controller source code: https://github.com/Daniel15/Website/blob/4aeb709b11db77543f16ef41b9018a3fb48de066/Daniel15.Web/Areas/Admin/Controllers/BlogController.cs
The text was updated successfully, but these errors were encountered: