System.InvalidOperationException:“Document is null”

未关闭
#445 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
28/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
csharp
领域
desktop

调研方向

在所示的 TabControl、AdvancedFileSearchVMTemplate 和 AvalonEdit TextEditor binding 下重现崩溃,同时后台 updateAction 更改 Document.Text。跟踪标签页切换和编辑器更新的顺序;完成标准是从标签页 B 切换到标签页 A 不再抛出 InvalidOperationException,同时更新仍能安全地继续进行。

由索引模型根据 Issue 内容生成。

描述

xmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"


<TabControl.ItemTemplate>





</TabControl.ItemTemplate>

<local:FileSearchViewSelector x:Key="selector" BasicFileMergeTemplate="{StaticResource BasicFileMergeVMTemplate}"
AdvancedFileSearchTemplate="{StaticResource AdvancedFileSearchVMTemplate}" />

AdvancedFileSearchVMTemplate is:

...skip others...
<avalonEdit:TextEditor
x:Name="TextEditor"
Grid.Row="1"
Document="{Binding Document}"
SyntaxHighlighting="{x:Null}"
ShowLineNumbers="True"
WordWrap="False"
FontFamily="Consolas"
FontSize="12"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto"
behaviors:TextEditorExtension.Register="{Binding RegisterEditorCommand}"
/>
...skip others...

a new tab item (B) is created after the search button was clicked. the backgroud task is runing and update the TextEditor with ::
editor?.BeginChange();
try
{
updateAction?.Invoke();
}
finally
{
editor.EndChange();
if (_autoScroll)
editor.ScrollToEnd();
}

updateAction:
Document.Text = value;

if we switch to tab item A, the system is crashed :
System.InvalidOperationException:“Document is null”
if we dont switch to A, say stay with B, it's ok... we can add code to check if Document is null but it's not the case.

please, any help will be appreciated.

主要语言
C#
星标
2.1k
派生
496
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

icsharpcode/AvalonEdit 的其他 Issue

查看 icsharpcode/AvalonEdit 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。