troygoode / MembershipStarterKit

The starter kit provides the Asp.Net MVC controllers, models, and views needed to administer users & roles.
http://github.com/TroyGoode/MembershipStarterKit
MIT License
198 stars 66 forks source link

Inheritance security rules violated with MVC5 #37

Open lacoursieresimon opened 10 years ago

lacoursieresimon commented 10 years ago

I just upgraded from MVC 4 to 5 and this error appeared :

Inheritance security rules violated while overriding member: 'MvcMembership.TouchUserOnEachVisitFilter'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.

It seems there is a problem with the 'MvcMembership.TouchUserOnEachVisitFilter' class in MV5. From what I understand, the security level is not high enough for the new MVC5 security policy. I fixed some of the errors I had by updating PagedListPager and MvcMembership via the PMC.Could it be related to the fact that the AssemblyInfo.cs has this assembly line ?

[assembly: AllowPartiallyTrustedCallers] 

It seems to be related to the PagedListPager issue #68. The line that causes the error is :

GlobalFilters.Filters.Add(new TouchUserOnEachVisitFilter());

Here is the whole code in the MvcMembership.cs file in App_Start

using System.Web.Mvc;
using MvcMembership;

[assembly: WebActivator.PreApplicationStartMethod(typeof(Seika_Tracker.App_Start.MvcMembership), "Start")]

namespace Seika_Tracker.App_Start
{
    public static class MvcMembership
    {
        public static void Start()
        {
            GlobalFilters.Filters.Add(new TouchUserOnEachVisitFilter());
        }
    }
}

Thank you

mkeuschn commented 10 years ago

Hello,

I have the same Problem, after I have updated to MVC 5.

I have also updated these packages:

Stacktrace

[TypeLoadException: Die Vererbungssicherheitsregeln wurden von Typ "MvcMembership.TouchUserOnEachVisitFilter" verletzt. Abgeleitete Typen müssen entweder mit dem Sicherheitszugriff des Basistyps übereinstimmen oder weniger zugreifbar sein.]
   NursingHome.MvcMembership.Start() in c:\workspace\NursingHomeStock\NursingHomeStock\App_Start\MvcMembership.cs:13

[TargetInvocationException: Ein Aufrufziel hat einen Ausnahmefehler verursacht.]
   System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +192
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +155
   System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +19
   WebActivator.BaseActivationMethodAttribute.InvokeMethod() +236
   WebActivator.ActivationManager.RunActivationMethods() +370
   WebActivator.ActivationManager.RunPreStartMethods() +41
   WebActivator.ActivationManager.Run() +64

[InvalidOperationException: Von der Methode "Run" des Typs "WebActivator.ActivationManager" für die Initialisierung vor dem Anwendungsstart wurde eine Ausnahme mit folgender Fehlermeldung ausgelöst: Ein Aufrufziel hat einen Ausnahmefehler verursacht..]
   System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +556
   System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +132
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +102
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +153
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +516

[HttpException (0x80004005): Von der Methode "Run" des Typs "WebActivator.ActivationManager" für die Initialisierung vor dem Anwendungsstart wurde eine Ausnahme mit folgender Fehlermeldung ausgelöst: Ein Aufrufziel hat einen Ausnahmefehler verursacht..]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9885044
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

best regards, Marko

velum commented 10 years ago

I propose the following fix for this issue:

https://github.com/velum/MembershipStarterKit/compare/troygoode:master...patch-1?quick_pull=1

It corrected the error for me.

angelost commented 10 years ago

Thanks @velum