This is a migrated thread and some comments may be shown as answers.

Problem with image inside RichTextBox

13 Answers 260 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 13 Feb 2012, 11:05 PM
I can insert an image into RTB through the ribbon icon for inserting images. When I click on the image(left/right click) I get the following error and empty page:

throw new Error("Unhandled Error in Silverlight Application Object reference not set to an instance of an object.
   at Telerik.Windows.Documents.UI.Extensibility.MiniToolBarManager.ShowImageMiniToolBar()\n  
   at Telerik.Windows.Documents.UI.Extensibility.MiniToolBarManager.RegisterSelectionChanged()\n  
   at Telerik.Windows.Documents.RichTextBoxCommands.ContextListeners.DocumentContextListener.ContextChangedEventHandler(Object sender, EventArgs e)\n  
   at System.EventHandler.Invoke(Object sender, EventArgs e)\n  
   at Telerik.Windows.Documents.Selection.DocumentSelection.OnSelectionChanged()\n  
   at Telerik.Windows.Documents.Selection.DocumentSelection.AddSelectionEnd(DocumentPosition position, Boolean shouldExpandRanges)\n  
   at Telerik.Windows.Documents.Selection.MouseSelectionHandler.SelectImage(LayoutBox layoutBoxNode)\n  
   at Telerik.Windows.Documents.Selection.MouseSelectionHandler.RegisterDocumentSingleMouseDown(Boolean ctrlPressed, Boolean shiftPressed, Point position, UIElement originalSource)\n  
   at Telerik.Windows.Documents.Selection.MouseSelectionHandler.RegisterDocumentMouseDown(Boolean ctrlPressed, Boolean shiftPressed, Point position, UIElement originalSource)\n  
   at Telerik.Windows.Documents.UI.DocumentPresenterBase.Owner_MouseLeftButtonDown(Object sender, MouseButtonEventArgs e)\n  
   at MS.Internal.CoreInvokeHandler.InvokeEventHandler(UInt32 typeIndex, Delegate handlerDelegate, Object sender, Object args)\n  
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName, UInt32 flags)");

Call stack window: JScript global code.
Maybe this information would be helpful.

That happens in IE(9 in my case). It seems working OK In Firefox.
Thanks in advance.

Tania

13 Answers, 1 is accepted

Sort by
0
Alex
Telerik team
answered on 17 Feb 2012, 09:38 AM
Hello,

Unfortunately we were unable to reproduce the exception. We would appreciate if you could open a support ticket and send us a sample project that demonstrates the issue so that we can further investigate it. Also any additional information about your scenario will be useful too. This includes:
- Do you have any customizations on the ImageMiniToolbar which seems to be in the root of the stack trace.
- Is there anything specific about the document that is currently loaded in the rad rich text box.
- Does this happen with different images.
- Is the issue present in the Q1 2012 release if you tried updating.

Thanks in advance! 

Regards,
Alex
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
PaulH
Top achievements
Rank 1
answered on 03 Mar 2012, 04:31 PM
Hello

I've been running some testing on an application (Silverlight 4) I have that I have incorporated a version of your RichTextBox editor from your demos and I'm having a similar problem with images in the RichTextBox. I can left-click to select them but if I then right-click I see the context menu briefly and then it crashes reporting the following unhandled error:

Line: 95
Error: Unhandled Error in Silverlight Application
Code: 2531    
Category: ParserError       
Message: Failed to assign to property 'System.Windows.Controls.ContentPresenter.Content'.     
File:      
Line: 514     
Position: 76     

Also, if I select it with left-click and then select Copy from the ribbon it will not Paste the image into another RichTextBox. Surely it should do this? I'm on the following version: 2012.1.227.1040 and running in IE9.

Hope this helps you to track this down.
0
Iva Toteva
Telerik team
answered on 07 Mar 2012, 02:38 PM
Hello Paul,

I was not able to reproduce either of the problems you have described.

Please find attached the demo I used for testing. If you succeed in achieving the same behavior with the demo, we would appreciate it if you could list the steps. It will also help if you turned on the option to break on every exception and copy the whole stack trace of the exception.

 Looking forward to your reply.

All the best,
Iva Toteva
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
PaulH
Top achievements
Rank 1
answered on 07 Mar 2012, 04:36 PM
Thanks for your reply and sample code. I've setup and run the code here and I find I can copy and paste images between the two windows in the sample app you provided. I am still having the right click issue with your sample though. If I change back to 2011.3.1330.1040 when I right click the inserted image I get no error dialog at all, it simply appears to crash the Silverlight plug-in. Re-upgrading the project to 2012.1.227.1040 and I get back to my original issue whereby I right click the image and immediately get the error I reported before. I am running on Silverlight 4 and I have no elements of Silverlight 5 installed at all in case that makes a difference. I've run your code with a breakpoint on the unhandled exception handler in the App.xaml.cs and it simply returns the following error:

Error: Unhandled Error in Silverlight Application Error HRESULT E_FAIL has been returned from a call to a COM component.

The exception object does not have a stack trace.

All I'm doing to get this is run your sample, click in the left RichTextBox and insert an image - I'm using the Windows 7 sample Koala.jpg. I then left click the image to select it and then right mouse click. I see the context menu appear rapidly followed by the error. I cannot seem to get any more of a stack trace than that.

0
Iva Toteva
Telerik team
answered on 12 Mar 2012, 07:04 PM
Hi Paul,

Thank you for the follow up.

We managed to reproduce the problem when only Silverlight 4 is installed on the machine. We have logged the issue, but we may not manage to fix it before the upcoming service pack.

We have updated your Telerik points in appreciation of your involvement.

Regards,
Iva Toteva
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
PaulH
Top achievements
Rank 1
answered on 13 Mar 2012, 12:18 AM
Hi Iva and thanks for the response.

I think from the previous responses it looks like we at least have a workaround anyway, to move to Silverlight 5 as it appears it will work correctly on that. I know it's something we'll need to do shortly before we complete the project for go live but I've been holding off as long as possible to save any pain at this phase of the development process.

Thanks again.
0
Iva Toteva
Telerik team
answered on 13 Mar 2012, 07:06 PM
Hello Paul,

You are right, if Silverlight 5 is installed on the client machine, the issue with the ContextMenu must not appear. Therefore, if your application targets Silverlight 5, clients will be prompted to install Silverlight 5 and the issue will not appear.

Kind regards,
Iva Toteva
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
PaulH
Top achievements
Rank 1
answered on 15 Mar 2012, 12:09 AM
Hi Iva

Well, I bit the bullet and upgraded to Silverlight 5 this afternoon and evening and as you and I expected it does now work properly so thanks for your time on that.

I have noticed another issue though which I can't be sure whether it was there before or not. I have the RichTextBox with the full Ribbon (like your Editor example) displayed in a RadWindow. When I click the button for the Styles Gallery nothing appears to happen. To start with I didn't think too much about it and carried on editing the dummy text I was using. However, when I closed the RadWindow the Styles Gallery was then visible so I think it must be getting loaded behind the RichTextBox Window. I've had a look and I don't seem to have control over where and how the Styles Gallery is loaded. Is there some way I can stop this from happening? The alternative would I guess be to move the RichTextBox into a UserControl and to load that into the Visual Tree when I want it but having it in a Window works quite nicely for what I'm trying to do. Sorry for appending this to the other item. I can open a new one if you'd prefer.

Any suggestions?

Thanks and regards
0
Iva Toteva
Telerik team
answered on 19 Mar 2012, 06:03 PM
Hi Paul,

Thank you for pointing out this issue. With the current version of controls, showing a non-dialog window such as ManageStylesDialog over another window works only the first time you open the new window. If the non-dialog window (ManageStylesDialog) loses focus to the bigger window, it will be hidden and it will not be possible to show it again if the bigger window is modal.

We will bring this issue up with the team developing RadWindow to see if they are considering changing this behavior in the future.

Regards,
Iva Toteva
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Stefan Falz
Top achievements
Rank 1
answered on 31 Mar 2012, 01:43 AM
Hi Iva,

i've updated to the Silverlight 4 binaries (Version 2012.1.326.1040) today and since the update each right click on an image results in the following error. Because i think the reason for this error should be the same or at least similar to Paul's, i thought, my posting was in the right place here.

In my case, the error occurs in all browsers (IE 9, Firefox 11, Chrome, ...)

Unhandled Error in Silverlight Application
Code: 2531
Category: ParserError
Message: Fehler beim Zuweisen zu Eigenschaft 'System.Windows.Controls.ContentPresenter.Content'.
File:
Line: 6099
Position: 65
 
throw new Error(errMsg);

This is only the result in the browser. I can't catch this exception in silverlight so i can't tell you more details, sorry.
The error message is in german. In english this should be someting like:
  Failed to assign to property

I used the Q3 2011 binaries (version 2011.3.1220.1040) before (until yesterday) and with this version all is fine. No error, no problems. (With images, some other things such as printing, replacing, ... made the update neccessary, so i can't go back to the old version).

0
Iva Toteva
Telerik team
answered on 04 Apr 2012, 03:18 PM
Hello Stefan,

Thank you for contacting us. It seems that the problem occurred only after 2011 Q3 SP1 (2011.3.1220).

We have logged the issue for revision, but it has not been addressed yet.

You can follow our progress on this item using PITS:
You can follow the PITS Issue by its ID: 10614
Public Url: http://www.telerik.com/support/pits.aspx#/public/silverlight/10614 

Regards,
Iva Toteva
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Stefan Falz
Top achievements
Rank 1
answered on 04 Apr 2012, 04:44 PM
Hi Iva,

please take a look at another thread in your forums.

  http://www.telerik.com/community/forums/silverlight/menu/silverlight-crash-opening-context-menu.aspx

I think, the problem has the same reason. Maybe it helps you to find the bug.

And yes, the problem occurs for each version after 2011.3.1220 for me.
0
Vasil
Telerik team
answered on 09 Apr 2012, 01:39 PM
Hello Stefan,

Thank you for your cooperation.
We have contacted the development team responsible for RadContextMenu and at this stage of examination it seems that the problem is caused by the Text Wrapping context menu group which is available on right click over an image. We need to investigate it further to apply an appropriate fix, so you can track the PITS issue we created.
A sample workaround for you can be to create a custom context menu (this help article describes how), which overrides the CreateFloatingBlockCommands method accountable for Text Wrapping context menu group. The override should return NULL to prevent the application from crashing.
Don't hesitate to contact us if you have other questions.

Greetings,
Vasil
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
RichTextBox
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Alex
Telerik team
PaulH
Top achievements
Rank 1
Iva Toteva
Telerik team
Stefan Falz
Top achievements
Rank 1
Vasil
Telerik team
Share this question
or