question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception: Source array was not long enough. Check srcIndex and length, and the array's lower bounds.

See original GitHub issue

I’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:closed
  • Created 6 years ago
  • Comments:36 (15 by maintainers)

github_iconTop GitHub Comments

9reactions
campbelljacommented, Dec 7, 2018

Hello everyone: Is another maintainer able to publish a release of @toddams 's changes please?

5reactions
tkdarrencommented, Oct 8, 2018

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Source array was not long enough. Check srcIndex and ...
Source array was not long enough. Check srcIndex and length, and the array's lower bounds · You're doing a Parallel loop and adding...
Read more >
How do "source array was not long enough. Check ...
Check srcindex and length, and the array's lower bounds."I... I seem to get this error "occasionally", more often than not when I stop...
Read more >
File Loading is failing with exception "Source array was not ...
Workbook which is throwing exception with message “Source array was not long enough. Check srcIndex and length, and the array's lower bounds.
Read more >
C# Source array was not long enough. Check srcIndex and ...
Check srcIndex and length, and the array's lower bounds for Array.Copy. c++exception. I have implemented multiple client and server. The client sends tcp...
Read more >
Source array was not long enough. Check ... - YouTrack
Check srcIndex and length, and the array's lower bounds. — EXCEPTION #1/2 [ArgumentException] Message = “Source array was not long enough.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found