Exception: Source array was not long enough. Check srcIndex and length, and the array's lower bounds.
See original GitHub issueI’ve got a really weird error going on here with our Azure App Service deployment related to RazorLight.
I’ve been running 2.0-alpha3
for several days now in Azure App Services without issue. Then all of a sudden this evening (without anything changing on our end) our app starts getting 500 errors from anything that invokes RazorLight (sending emails).
Source array was not long enough. Check srcIndex and length, and the array’s lower bounds.
at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)\r\n
at System.Collections.Immutable.ImmutableExtensions.TryCopyTo[T](IEnumerable`1 sequence, T[] array, Int32 arrayIndex)\r\n
at System.Collections.Immutable.ImmutableExtensions.ToArray[T](IEnumerable`1 sequence, Int32 count)\r\n
at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)\r\n
at Microsoft.CodeAnalysis.ImmutableArrayExtensions.AsImmutableOrEmpty[T](IEnumerable`1 items)\r\n
at Microsoft.CodeAnalysis.Compilation.ValidateReferences[T](IEnumerable`1 references)\r\n
at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.Create(String assemblyName, CSharpCompilationOptions options, IEnumerable`1 syntaxTrees, IEnumerable`1 references, CSharpCompilation previousSubmission, Type returnType, Type hostObjectType, Boolean isSubmission)\r\n
at RazorLight.Compilation.RoslynCompilationService.CreateCompilation(String compilationContent, String assemblyName)\r\n
at RazorLight.Compilation.RoslynCompilationService.CompileAndEmit(GeneratedRazorTemplate razorTemplate)\r\n
at RazorLight.TemplateFactoryProvider.CreateFactory(GeneratedRazorTemplate razorTemplate)\r\n
at RazorLight.TemplateFactoryProvider.<CreateFactoryAsync>d__4.MoveNext()\r\n
--- End of stack trace from previous location where exception was thrown ---\r\n
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
at RazorLight.RazorLightEngine.<CompileTemplateAsync>d__10.MoveNext()\r\n
--- End of stack trace from previous location where exception was thrown ---\r\n
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
at RazorLight.RazorLightEngine.<CompileRenderAsync>d__9.MoveNext()\r\n
--- End of stack trace from previous location where exception was thrown ---\r\n
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
at Bit.Core.Services.RazorMailService.<SendMasterPasswordHintEmailAsync>d__9.MoveNext()\r\n
--- End of stack trace from previous location where exception was thrown ---\r\n
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
at Bit.Core.Services.UserService.<SendMasterPasswordHintAsync>d__26.MoveNext()\r\n
--- End of stack trace from previous location where exception was thrown ---\r\n
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
at Bit.Api.Controllers.AccountsController.<PostPasswordHint>d__8.MoveNext()\r\n
--- End of stack trace from previous location where exception was thrown ---\r\n
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__12.MoveNext()\r\n
--- End of stack trace from previous location where exception was thrown ---\r\n
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__10.MoveNext()\r\n
--- End of stack trace from previous location where exception was thrown ---\r\n
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)\r\n
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeInnerFilterAsync>d__14.MoveNext()\r\n
--- End of stack trace from previous location where exception was thrown ---\r\n
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextExceptionFilterAsync>d__23.MoveNext()",
I restart the server and even re-deployed the code, but the error remains every time something uses RazorLight. I don’t really understand what has changed all of a sudden to cause this issue.
Locally I can execute the same RazorLight code without issue. See source here: https://github.com/bitwarden/core/blob/master/src/Core/Services/Implementations/RazorMailService.cs
Any ideas what is going on here?
Issue Analytics
- State:
- Created 6 years ago
- Comments:36 (15 by maintainers)
Top GitHub Comments
Hello everyone: Is another maintainer able to publish a release of @toddams 's changes please?
For anyone experiencing this issue, I was able to fix it after @toddams closed this issue on 8th June by cloning the latest commit of the master branch and compiling the RazorLight plugin myself in Visual Studio. This is because there hasn’t been any release since the issue was fixed containing the fix. I then referenced my compiled RazorLight in my projects and I haven’t had the issue since. I’ve attached a zip file of the RazorLight that I compiled which is working well for me, I will note that the version I’ve attached was compiled back in June and therefore is probably outdated now.
You just need to uninstall any version that you already have installed beforehand and reference the compiled version in your projects (Right click project -> Add -> Reference in Visual Studio 2017) RazorLight.zip