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

System.Security.VerificationException with Performance Profiler

5 Answers 59 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Devin
Top achievements
Rank 1
Devin asked on 06 Feb 2012, 07:00 PM
While using RedGate ANTS Performance Profiler, I get to a point in my application where I click on a RadButton.  Through the event handlers that subsequently get fired, I eventually get the following error:

System.Windows.Markup.XamlParseException: The type initializer for 'Telerik.Windows.Controls.RichTextBoxUI.RadRichTextBoxRibbonUI' threw an exception. ---> System.Security.VerificationException: Operation could destabilize the runtime.

This only occurs when I'm running the profiler and so far, only in this one place.  The view that it's trying to initialize doesn't explicitly use the RadRichTextBoxRibbonUI.  It only uses RadWrapPanels and a RadComboBox.

Seeing how this doesn't happen during normal execution, it's hard to identify a cause within my implementation.  Also, not knowing the intrinsic behavior of how the performance profiler sets stuff up, I don't know what the difference would be.  

Any thoughts?

Stack Trace:
************** Exception Text **************
System.Windows.Markup.XamlParseException: The type initializer for 'Telerik.Windows.Controls.RichTextBoxUI.RadRichTextBoxRibbonUI' threw an exception. ---> System.Security.VerificationException: Operation could destabilize the runtime.
   at Telerik.Windows.Controls.RichTextBoxUI.RadRichTextBoxRibbonUI..cctor() in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Documents\RichTextBoxUI\RichTextBoxUI\RadRichTextBoxRibbonUI.cs:line 32
   --- End of inner exception stack trace ---
   at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
   at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
   at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
   at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
   at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
   at Xm8.UI.EWD2.MacroItemView.InitializeComponent() in c:\sd\Trunk\xm8\Asm\UI\EWD2\MacroItemView.xaml:line 1
   at Xm8.UI.EWD2.MacroItemView..ctor() in c:\sd\Trunk\xm8\Asm\UI\EWD2\MacroItemView.xaml.cs:line 34
   at Xm8.UI.EWD2.MacroDialog..ctor() in c:\sd\Trunk\xm8\Asm\UI\EWD2\MacroDialog.cs:line 100
   at Xm8.UI.EWD2.MacroSLView.ShowMacroDialog(IXm8State xm8State, String oldMacroCode, MacroDoc macroDoc, EDPL edpl, MacroOperation macroOperation) in c:\sd\Trunk\xm8\Asm\UI\EWD2\MacroSLView.xaml.cs:line 50
   at Xm8.EWD2.MP.Model.Macro.MacroSLModel.DoShowMacroDialog(MacroDoc macroDoc) in c:\sd\Trunk\xm8\Asm\MP\EWD2.MP\Model\Macro\MacroSLModel.cs:line 382
   at Xm8.EWD2.MP.Model.Macro.MacroSLModel.OnAdd() in c:\sd\Trunk\xm8\Asm\MP\EWD2.MP\Model\Macro\MacroSLModel.cs:line 351
   at Core.Sys.RelayCommand.Execute(Object parameter) in c:\sd\Trunk\core\Asm\Sys\Sys\RelayCommand.cs:line 67
   at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource commandSource, Boolean userInitiated)
   at System.Windows.Controls.Primitives.ButtonBase.OnClick()
   at System.Windows.Controls.Button.OnClick()
   at Telerik.Windows.Controls.RadButton.OnClick() in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\Buttons\RadButton.cs:line 388
[truncated]

5 Answers, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 07 Feb 2012, 05:55 PM
Hi Devin,

We have not encountered such an issue. 

Some of the information that we found on this exception in general is that it is related to the changes in the Security Model in WPF 4.0This article and this blogpost show possible approaches for resolving what seems to be a similar issue. If your application is XBAP, the problem may also be related to the permissions not covering the minimum permission set required by RadRichTextBox and RadRichTextBoxRibbonUI.

If this does not help you narrow down the cause, we would appreciate it if you could isolate the problem in a sample application. You can open a support ticket about the issue and attach a zip there. If you decide to do so, please make sure to include information of the exact version of the controls you are using, e.g. 2011.3.1220.40. 

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
Devin
Top achievements
Rank 1
answered on 12 Mar 2012, 06:00 PM
I've actually begun to see the issue during login which has crippled my ability to perform and sort of analysis. The same exception (System.VerificationException: Operation...) is being thrown but this time is originates from a different Telerik control.  

The booleanfrog blogpost you mentioned seemed to be very helpful.  Per his suggestion I added:
using System.Security;
  
[assembly: SecurityRules(SecurityRuleSet.Level1)]

but I still encounter the issue. 

Here is the stack trace:

at Telerik.Windows.Documents.Proofing.Converters.BoolToVisibilityConverter.Convert(Object value, Type targetType, Object parameter, CultureInfo culture) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Documents\Proofing\Core\Converters\BoolToVisibilityConverter.cs:line 11
   at Core.UI.Converters.BoolToVisibilityConverter.Convert(Object value, Type targetType, Object parameter, CultureInfo culture) in c:\sd\Trunk\core\Asm\UI\Converters\BoolToVisibilityConverter.cs:line 25
   at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
   at System.Windows.Data.BindingExpression.Activate(Object item)
   at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt)
   at System.Windows.Data.BindingExpression.AttachOverride(DependencyObject target, DependencyProperty dp)
   at System.Windows.Data.BindingExpressionBase.Attach(DependencyObject target, DependencyProperty dp)
   at System.Windows.Data.BindingExpressionBase.OnAttach(DependencyObject d, DependencyProperty dp)
   at System.Windows.StyleHelper.GetInstanceValue(UncommonField`1 dataField, DependencyObject container, FrameworkElement feChild, FrameworkContentElement fceChild, Int32 childIndex, DependencyProperty dp, Int32 i, EffectiveValueEntry& entry)
   at System.Windows.FrameworkTemplate.ReceivePropertySet(Object targetObject, XamlMember member, Object value, DependencyObject templatedParent)
   at System.Windows.FrameworkTemplate.<>c__DisplayClass6.<LoadOptimizedTemplateContent>b__4(Object sender, XamlSetValueEventArgs setArgs)
   at System.Xaml.XamlObjectWriter.OnSetValue(Object eventSender, XamlMember member, Object value)
   at System.Xaml.XamlObjectWriter.SetValue(Object inst, XamlMember property, Object value)
   at System.Xaml.XamlObjectWriter.Logic_ApplyPropertyValue(ObjectWriterContext ctx, XamlMember prop, Object value, Boolean onParent)
   at System.Xaml.XamlObjectWriter.Logic_DoAssignmentToParentProperty(ObjectWriterContext ctx)
   at System.Xaml.XamlObjectWriter.Logic_AssignProvidedValue(ObjectWriterContext ctx)
   at System.Xaml.XamlObjectWriter.WriteEndObject()
   at System.Xaml.XamlWriter.WriteNode(XamlReader reader)
   at System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlReader templateReader, XamlObjectWriter currentWriter)


Is it possible that since the exception is originating from your control you need to add the aforementioned security attribute?  
0
Boby
Telerik team
answered on 15 Mar 2012, 09:08 AM
Hello Devin,
It looks like ANTS has some problems with profiling applications that don't run in full trust. You could check this forum thread in ANTS Performance Profiler 6 forum for possible solutions or try to remove any security restrictions you have applied to the profiled application and run it in full trust during the profiling.

Don't hesitate to contact us if this doesn't solve the problem.


Regards,
Boby
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
Devin
Top achievements
Rank 1
answered on 15 Mar 2012, 05:09 PM
I understand that part.  I've tried making security changes to our application, but as I mentioned previously, this doesn't resolve the issue. I've been able to profile our application for months without problems.  We only started having these problems when we updated our telerik dlls.

I'm continuing to search/work with RedGate to see if there is another potential solution, I just wanted to see if there was any changes that you might want/need to make to your .net 4.0 dlls with the change in security that was introduced to avoid issues when instrumenting code.
0
Boby
Telerik team
answered on 20 Mar 2012, 05:32 PM
Hi Devin,

We haven't changed the security attributes of our assemblies. What is more, we created a Test application using the Telerik assemblies related to RadRichTextBox and RadRichTextBoxRibbonUI and profiled it. Everything went as expected and we were not able to reproduce the VerificationException issue.

 If you manage to isolate the problem in a sample project, you can send it to us (attached to a support ticket), so that we can investigate the issue further.

Looking forward to your reply.

Greetings,
Boby
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
Devin
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Devin
Top achievements
Rank 1
Boby
Telerik team
Share this question
or