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

ScanHashtagsCommand [Ctrl+ALt+F9] = Exception "The index and length must refer to a location within the string" #1683

Open
nhwCoder opened this issue Nov 26, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@nhwCoder
Copy link

Problem to Solve

ScanHashtagsCommand [Ctrl+ALt+F9] results in Exception (see log below)

To Reproduce

Steps to reproduce the behavior:

  1. Add a link
    • Address: C:\
    • Text: Link ##Test ##Test
  2. Use keytip [Ctrl+ALt+F9] ScanHashtagsCommand
  3. See error below

Environment (if applicable)

  • OneMore Version 6.6.1
  • OneNote 16.0.18129.20158

The Exception

07|02:14:22.682| Running command ScanHashtagsCommand
07|02:14:23.687| Error running command ScanHashtagsCommand
07|02:14:23.687| System.ArgumentOutOfRangeException
Message: Der Index und die Länge müssen sich auf eine Position in der Zeichenfolge beziehen.
=====> (+/-)EN: "The index and length must refer to a location within the string."
Parametername: length
Source: mscorlib
StackTrace: bei System.String.Substring(Int32 startIndex, Int32 length)
bei River.OneMoreAddIn.Commands.TextAtom.Replace(Int32 index, Int32 length, XElement replacement)
bei River.OneMoreAddIn.Commands.ElementAtom.Replace(Int32 index, Int32 length, XElement replacement)
bei River.OneMoreAddIn.Commands.SearchAndReplaceEditor.Replace(XElement wrapper, Int32 searchIndex, Int32 searchLength, String stringValue, XElement elementValue)
bei River.OneMoreAddIn.Commands.SearchAndReplaceEditor.ScanElement(XElement element)
bei River.OneMoreAddIn.Commands.SearchAndReplaceEditor.SearchAndReplace(XElement paragraph)
bei River.OneMoreAddIn.Commands.HashtagPageScanner.Scan()
bei River.OneMoreAddIn.Commands.HashtagScanner.d__21.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter1.GetResult() bei River.OneMoreAddIn.Commands.HashtagScanner.<Scan>d__20.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
bei River.OneMoreAddIn.Commands.HashtagScanner.d__19.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
bei River.OneMoreAddIn.Commands.HashtagScanner.d__19.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.GetResult()
bei River.OneMoreAddIn.Commands.ScanHashtagsCommand.d__1.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei System.Runtime.CompilerServices.TaskAwaiter.GetResult()
bei River.OneMoreAddIn.CommandFactory.d__6.MoveNext()
TargetSite: [mscorlib] System.String::Substring()

@nhwCoder nhwCoder added bug Something isn't working unread I have seen it or had time to refine it yet labels Nov 26, 2024
@stevencohn stevencohn removed the unread I have seen it or had time to refine it yet label Nov 26, 2024
@nhwCoder nhwCoder changed the title ScanHashtagsCommand - Exception ScanHashtagsCommand [Ctrl+ALt+F9] - Exception Nov 26, 2024
@stevencohn
Copy link
Owner

stevencohn commented Nov 26, 2024

@nhwCoder I'm not sure what you mean by this. Can you explain more or show a picture please?

  1. Add a link
    • Address: C:\
    • Text: Link ##Test ##Test

@nhwCoder nhwCoder changed the title ScanHashtagsCommand [Ctrl+ALt+F9] - Exception ScanHashtagsCommand [Ctrl+ALt+F9] = Exception "The index and length must refer to a location within the string" Nov 26, 2024
@nhwCoder
Copy link
Author

nhwCoder commented Nov 27, 2024

You are right, I could describe it better

  • Create a new empty page

  • First: Add a link "aaa #bbb #ccc" that points to c:

  • Then: Add below in next line the text ddd
    This now looks like
    image
    image

  • Now: Run 2 or more times the keytip [Ctrl+Alt+F9]
    RESULT: The following exception is thrown
    image

Info: See exception text above

@stevencohn
Copy link
Owner

stevencohn commented Dec 2, 2024

Note to self: The Ctrl+Alt+F9 request is not the problem, but rather the subsequent automated scanner that then doesn't recognize the highlighted tag. The offending XML:

<one:T>
  <![CDATA[<a href="c:">aaa <span style='background:#FFFF99'>#abb</span> <span style='background:#FFFF99'>#acc</span></a>]]>
</one:T>

And a more complete stack trace:

03|08:07:24.737| hashtag service exception 4
System.ArgumentOutOfRangeException
Message: Index and length must refer to a location within the string.
Parameter name: length
Source: mscorlib
StackTrace:    at System.String.Substring(Int32 startIndex, Int32 length)
   at River.OneMoreAddIn.Commands.TextAtom.Replace(Int32 index, Int32 length, XElement replacement) in C:\Github\OneMore\OneMore\Commands\Search\Atoms\TextAtom.cs:line 58
   at River.OneMoreAddIn.Commands.ElementAtom.Replace(Int32 index, Int32 length, XElement replacement) in C:\Github\OneMore\OneMore\Commands\Search\Atoms\ElementAtom.cs:line 61
   at River.OneMoreAddIn.Commands.SearchAndReplaceEditor.Replace(XElement wrapper, Int32 searchIndex, Int32 searchLength, String stringValue, XElement elementValue) in C:\Github\OneMore\OneMore\Commands\Search\SearchAndReplaceEditor.cs:line 300
   at River.OneMoreAddIn.Commands.SearchAndReplaceEditor.ScanElement(XElement element) in C:\Github\OneMore\OneMore\Commands\Search\SearchAndReplaceEditor.cs:line 208
   at River.OneMoreAddIn.Commands.SearchAndReplaceEditor.SearchAndReplace(XElement paragraph) in C:\Github\OneMore\OneMore\Commands\Search\SearchAndReplaceEditor.cs:line 120
   at River.OneMoreAddIn.Commands.HashtagPageScanner.Scan() in C:\Github\OneMore\OneMore\Commands\Tagging\HashtagPageScanner.cs:line 116
   at River.OneMoreAddIn.Commands.HashtagScanner.<ScanPage>d__21.MoveNext() in C:\Github\OneMore\OneMore\Commands\Tagging\HashtagScanner.cs:line 379
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at River.OneMoreAddIn.Commands.HashtagScanner.<Scan>d__20.MoveNext() in C:\Github\OneMore\OneMore\Commands\Tagging\HashtagScanner.cs:line 299
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at River.OneMoreAddIn.Commands.HashtagScanner.<Scan>d__19.MoveNext() in C:\Github\OneMore\OneMore\Commands\Tagging\HashtagScanner.cs:line 229
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at River.OneMoreAddIn.Commands.HashtagScanner.<Scan>d__19.MoveNext() in C:\Github\OneMore\OneMore\Commands\Tagging\HashtagScanner.cs:line 251
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at River.OneMoreAddIn.Commands.HashtagService.<Scan>d__21.MoveNext() in C:\Github\OneMore\OneMore\Commands\Tagging\HashtagService.cs:line 216
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at River.OneMoreAddIn.Commands.HashtagService.<StartupLoop>d__19.MoveNext() in C:\Github\OneMore\OneMore\Commands\Tagging\HashtagService.cs:line 126
TargetSite: [mscorlib] System.String::Substring()

03|08:07:24.737| hashtag service has stopped; check for exceptions above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants