You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
usingSystem;usingSystem.Collections.Generic;usingSystem.Diagnostics;usingSystem.Linq;usingSystem.Threading.Tasks;usingMicrosoft.AspNetCore.Authentication;usingMicrosoft.AspNetCore.Authorization;usingMicrosoft.AspNetCore.Identity;usingMicrosoft.AspNetCore.Mvc;usingMicrosoft.Extensions.Logging;usingNewtonsoft.Json;usingAuth.Data.Identity;usingAuth.Models;// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860namespaceAuth.Controllers{publicclassAccountController:Controller{privatereadonlySignInManager<User>signInManager;privatereadonlyILogger<AccountController>logger;publicAccountController(SignInManager<User>signInManager,ILogger<AccountController>logger){this.signInManager=signInManager;this.logger=logger;}[HttpGet][AllowAnonymous]publicasyncTask<IActionResult>Login(stringreturnUrl=null){returnUrl=returnUrl??Url.Content("~/");// Clear the existing external cookie to ensure a clean login processawaitHttpContext.SignOutAsync(IdentityConstants.ExternalScheme);varexternalLogin=(awaitsignInManager.GetExternalAuthenticationSchemesAsync()).First();returnRedirectToAction(nameof(ExternalLogin),new{provider=externalLogin.Name,returnUrl});}[HttpPost][ValidateAntiForgeryToken]publicasyncTask<IActionResult>LogOut(stringreturnUrl=null){awaitsignInManager.SignOutAsync();logger.LogInformation("User logged out.");if(returnUrl!=null){returnLocalRedirect(returnUrl);}else{returnRedirectToAction(nameof(HomeController.Index),"Home");}}[HttpGet][AllowAnonymous]publicIActionResultExternalLogin(stringprovider,stringreturnUrl=null){// Request a redirect to the external login provider.varredirectUrl=Url.Action("ExternalLoginCallback","Account",new{ReturnUrl=returnUrl});varproperties=signInManager.ConfigureExternalAuthenticationProperties(provider,redirectUrl);returnnewChallengeResult(provider,properties);}[HttpGet][AllowAnonymous]publicasyncTask<IActionResult>ExternalLoginCallback([FromServices]UserManager<User>userManager,stringreturnUrl=null,stringremoteError=null){returnUrl=returnUrl??Url.Content("~/");if(remoteError!=null)returnView("Error",newErrorViewModel{RequestId=Activity.Current?.Id??HttpContext.TraceIdentifier,ErrorDescription=$"Error from external provider: {remoteError}"});varinfo=awaitsignInManager.GetExternalLoginInfoAsync();if(info==null)returnView("Error",newErrorViewModel{RequestId=Activity.Current?.Id??HttpContext.TraceIdentifier,ErrorDescription="Error loading external login information."});// Sign in the user with this external login provider if the user already has a login.stringloginProvider=info.LoginProvider;varsignInResult=awaitsignInManager.ExternalLoginSignInAsync(loginProvider,info.ProviderKey,isPersistent:false,bypassTwoFactor:true);varidentity=info.Principal.Identity;if(signInResult.Succeeded){varuser=awaituserManager.FindByLoginAsync(loginProvider,info.ProviderKey);// TODO: Update user from identity using Automappervarprops=newAuthenticationProperties{IsPersistent=true};props.StoreTokens(info.AuthenticationTokens);awaitsignInManager.SignInAsync(user,props,loginProvider);logger.LogInformation("{Name} logged in with {LoginProvider} provider.",identity.Name,loginProvider);returnLocalRedirect(returnUrl);}else{// If the user does not have an account, create an account.varuser=newUser{// TODO: Use AutomapperSalesforceInstance=identity.GetInstanceUrl(),UserName=identity.GetUserName(),Email=identity.GetEmail(),FirstName=identity.GetFirstName(),LastName=identity.GetLastName(),SalesforceId=identity.GetSalesforceId(),SalesforceOrg=identity.GetSalesforceOrg(),Picture=identity.GetPicture(),Thumbnail=identity.GetThumbnail()};varcreateResult=awaituserManager.CreateAsync(user);if(createResult.Succeeded){createResult=awaituserManager.AddLoginAsync(user,info);if(createResult.Succeeded){varprops=newAuthenticationProperties();props.StoreTokens(info.AuthenticationTokens);awaitsignInManager.SignInAsync(user,props,loginProvider);logger.LogInformation("User created an account using {Name} provider.",loginProvider);returnLocalRedirect(returnUrl);}}foreach(varerrorincreateResult.Errors){ModelState.AddModelError(string.Empty,error.Description);}}returnBadRequest(ModelState);}}}
So I selected , string remoteError = null in ExternalLoginCallback method and deleted it.
Usually Visual Studio crashed without any info (see my discussion in Q&A)
However 1 time in event log I found crash with GitDiffMargin. Then I disabled GitDiffMargin and tried to investigate further to find the next cause of crash.
Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentException
at Microsoft.VisualStudio.Text.SnapshotSpan.EnsureSnapshot(Microsoft.VisualStudio.Text.ITextSnapshot)
at Microsoft.VisualStudio.Text.SnapshotSpan.IntersectsWith(Microsoft.VisualStudio.Text.SnapshotSpan)
at GitDiffMargin.EditorDiffMargin.UpdateNormalDiffDimensions(GitDiffMargin.ViewModel.DiffViewModel, GitDiffMargin.Git.HunkRangeInfo)
at GitDiffMargin.EditorDiffMargin.UpdateDiffDimensions(GitDiffMargin.ViewModel.DiffViewModel, GitDiffMargin.Git.HunkRangeInfo)
at GitDiffMargin.ViewModel.DiffViewModel.UpdateDimensions()
at GitDiffMargin.ViewModel.EditorDiffViewModel.UpdateDimensions()
at GitDiffMargin.ViewModel.EditorDiffViewModel..ctor(GitDiffMargin.Git.HunkRangeInfo, GitDiffMargin.Core.IMarginCore, System.Action`2<GitDiffMargin.ViewModel.DiffViewModel,GitDiffMargin.Git.HunkRangeInfo>)
at GitDiffMargin.ViewModel.EditorDiffMarginViewModel.CreateDiffViewModel(GitDiffMargin.Git.HunkRangeInfo)
at System.Linq.Enumerable+WhereSelectListIterator`2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].MoveNext()
at GitDiffMargin.ViewModel.DiffMarginViewModelBase.HandleHunksChanged(System.Object, GitDiffMargin.Core.HunksChangedEventArgs)
at GitDiffMargin.ViewModel.EditorDiffMarginViewModel.HandleHunksChanged(System.Object, GitDiffMargin.Core.HunksChangedEventArgs)
at System.EventHandler`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Invoke(System.Object, System.__Canon)
at GitDiffMargin.Core.MarginCore.OnHunksChanged(System.Collections.Generic.IEnumerable`1<GitDiffMargin.Git.HunkRangeInfo>)
at GitDiffMargin.Core.MarginCore+<>c__DisplayClass58_0.<HandleParseComplete>b__0()
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
Steps to Reproduce
Steps to reproduce the behavior:
Create ASP.NET Core 2.2 app
Add controller with code from above
Selected , string remoteError = null in ExternalLoginCallback method and deleted it.
xperiandri
changed the title
Draft: Visual Studio 2019 RTM crashes on method parameter add/remove
Visual Studio 2019 RTM crashes on method parameter add/remove
Apr 7, 2019
Versions
What happened
I had such controller in my ASP.NET Core 2.2 app
I also had C# Var Type CodeLens extension installed.
So I selected
, string remoteError = null
inExternalLoginCallback
method and deleted it.Usually Visual Studio crashed without any info (see my discussion in Q&A)
However 1 time in event log I found crash with GitDiffMargin. Then I disabled GitDiffMargin and tried to investigate further to find the next cause of crash.
Steps to Reproduce
Steps to reproduce the behavior:
, string remoteError = null
inExternalLoginCallback
method and deleted it.Additional context
Crash may occure with C# Var Type CodeLens extension
The text was updated successfully, but these errors were encountered: