2015-01-02 14 views
12

'üyenin kıldı ederken Kalıtım güvenlik kuralları ihlal' atar:Kaydol, MVC projesi ile birlikte gelen varsayılan Sayman kayıt fonksiyonu kullanıyorum benim okul projesi için

// POST: /Account/Register 
[HttpPost] 
[AllowAnonymous] 
[ValidateAntiForgeryToken] 
public async Task<ActionResult> Register(RegisterViewModel model){ 
    if (ModelState.IsValid){ 
     var user = new ApplicationUser(){UserName = model.UserName}; 
     var result = await UserManager.CreateAsync(user, model.Password); 
     if (result.Succeeded){ 
      await SignInAsync(user, isPersistent: false); 
      return RedirectToAction("Index", "Home"); 
     } 
     else{ 
      AddErrors(result); 
     } 
    } 

    // If we got this far, something failed, redisplay form 
    return View(model); 
} 

Ama kayıt düğmesine tıkladığınızda Benim formumda: Security accessibility of the overriding method must match the security accessibility of the method being overriden

Biraz aradık ve [SecurityCritical] ekleyerek düzeltmeniz gerektiğini buldum, ancak bunu bir eşzamanlama görevine ekleyemezsiniz.

[TypeLoadException: Inheritance security rules violated while overriding member: 'Microsoft.AspNet.Identity.TaskExtensions+CultureAwaiter`1<T>.UnsafeOnCompleted(System.Action)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.] 
    Microsoft.AspNet.Identity.UserManager`2.CreateAsync(TUser user, String password) +0 
    Admin.Controllers.<Register>d__8.MoveNext() +198 
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93 
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52 
    System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) +84 
    System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeAsynchronousActionMethod>b__36(IAsyncResult asyncResult) +17 
    System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10 
    System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49 
    System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32 
    System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +50 
    System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +225 
    System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +10 
    System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10 
    System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49 
    System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34 
    System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +26 
    System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100 
    System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10 
    System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49 
    System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27 
    System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13 
    System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +36 
    System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +54 
    System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +39 
    System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12 
    System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +28 
    System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +54 
    System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29 
    System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10 
    System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21 
    System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +36 
    System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +54 
    System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +31 
    System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9 
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9657896 
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155 
:

da [assembly: SecurityRules(SecurityRuleSet.Level1)] ekleyerek bunu yapmalıdır, ama aynı zamanda o Bu yalnızca (Entegre Boru Hattı ile sürüm 4.0 çalıştıran) benim yayımlamak sunucuya

StackTrace üzerindedir

çalışmıyor bulundu

+1

Alacağınız istisna StackTrace nedir? sınıfının kalıtımı, bir yerde 'özel' olması gereken yerde 'özel' 'kamusal' olmalıdır – trailmax

+0

@trailmax StackTrace eklendi – Kiwi

+0

Farklı bir çerçeve sürümünü test eden yeni bir proje oluşturmayı denediniz mi? 'UserManager.CreateAsync' yöntemini değiştirmediğiniz sürece, güven düzeyiniz bir şekilde veya çerçevedeki bir hata olmadığı sürece bunun neden olacağını anlayamıyorum. – Justin

cevap

0

Montajlar yalnızca GAC altında kaydedildiğinde tam güvence verilir. Derlemeniz özel bir meclisse, kısmi güven ve şeffaftır (example of transparent behavior). Derlemeniz bir private derleme olduğundan, Dot Net CLR, [SecurityCritical]'u yoksaydı.

private derlemesini kullanmaya devam etmeyi ve orta güvende çalışmaya devam etmeyi planlıyorsanız, bir [SecurityCritical] üyesini geçersiz kılmaya veya erişemezsiniz.

How to install an assembly into the Global Assembly Cache in Visual C#

+0

Seni tamamen takip etmiyor. Biraz daha açıklayabilir misin? Özellikle hisse senetleri neden GAC için ayarlanmayacaktı. veya bu varsayılan olarak yapılmayan bir şey mi? – Kiwi

+0

@Kiwi Hataların nedenini belirledim ve çözümlerim: 1- kullanılmış derleme güven düzeyini değiştirin veya 2-Orta güven ihlalini dikkate alarak (geçersiz kılınmak için) :) –