Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inheritance security rules violated with MVC5 #37

Open
lacoursieresimon opened this issue Jan 16, 2014 · 3 comments
Open

Inheritance security rules violated with MVC5 #37

lacoursieresimon opened this issue Jan 16, 2014 · 3 comments

Comments

@lacoursieresimon
Copy link

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
Copy link

mkeuschn commented Mar 5, 2014

Hello,

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

I have also updated these packages:

  • Install-Package PagedList
  • Install-Package PagedList.Mvc
  • Install-Package MvcMembership
  • Install-Package MvcMembership.Mvc
  • Install-Package CaptchaMvc.Mvc5

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
Copy link

velum commented Mar 12, 2014

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
Copy link

angelost commented Aug 4, 2014

Thanks @velum

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants