Framework-Class-Library-Extension
Framework-Class-Library-Extension copied to clipboard
Can't bind to property created by aspect supported dependency property factory
trafficstars
Sometimes binding properties within Xaml, created by the aspects version of the dependency property factory (WpfControl) throws the following exception: "A 'Binding' cannot be set on the 'Standard' property of type 'TestControl'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject."
The full stack trace of the failing unit test, XamlInitializationTest:
Initialization method Whathecode.Tests.System.Windows.DependencyPropertyFactory.Aspects.XamlTest.InitializeTest threw exception. System.Reflection.TargetInvocationException: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Windows.Markup.XamlParseException: A 'Binding' cannot be set on the 'Standard' property of type 'TestControl'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject..
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 XamlTests.Aspects.XamlControl.InitializeComponent() in XamlControl.xaml: line 1
at XamlTests.Aspects.XamlControl..ctor() in XamlControl.xaml.cs: line 11
--- End of inner exception stack trace ---
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, ref Boolean canBeCached, ref RuntimeMethodHandleInternal ctor, ref Boolean bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, ref StackCrawlMark stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, ref StackCrawlMark stackMark)
at System.Activator.CreateInstance()
at Whathecode.Tests.System.Windows.DependencyPropertyFactory.BaseXamlTest`1.InitializeTest() in BaseXamlTest.cs: line 15
The unit test somehow only seems to fail when ran individually, so I expect there to be some remnant state within the aspects which causes/prevents the problem from occurring.