2

I have a RichTextBox and when I try to drag & drop inside it it throws exception:

enter image description here

it happens when I'm in debug mode and the common language runtime exception flag is on.

This is my XAML -

<Grid>
    <RichTextBox x:Name="rtb"
                 ScrollViewer.VerticalScrollBarVisibility="Auto"
                 IsReadOnly="True" />
</Grid>

this is code behind -

public MainWindow()
{
  InitializeComponent();
  rtb.AppendText("aaaaaaa aaaaaaaaaaa aaaaaaaa aaaaaaaabbb bbbbb bbbbb bbbb");
}
LarsTech
  • 80,625
  • 14
  • 153
  • 225
Erez
  • 6,405
  • 14
  • 70
  • 124
  • 3
    Do you have to have the CLR Exception flag set? I think MS uses the exception system internally to handle some cases that you usually don't have to worry about, and that's where the exception is occurring. – Rachel Dec 12 '11 at 15:55
  • The exception you showed us has absolutely no link to a drag and drop, it's a click once exception. Also, the code behind you showed has no trace of a drag and drop towards any RichTextBox Control, however, as Rachel said, you should be okay without that flag set, this usually is to catch lower level unhandled exceptions. – Guillaume Cantin May 17 '12 at 02:50
  • Addendum to @Rachel's post, [this](http://stackoverflow.com/questions/4677756/what-causes-an-invaliddeploymentexception-in-a-wpf-application) is same issue. – Bob. Sep 19 '12 at 20:50

1 Answers1

1

Have you set AllowDrop = true ?
If you haven't, you can get bizarre errors

Anne
  • 26,765
  • 9
  • 65
  • 71
SvdSinner
  • 951
  • 1
  • 11
  • 23