XAMLMarkupExtensions/WPFLocalizeExtension

NullReference exception in wpf designer

ruudsieb opened this issue · 6 comments

I often get a NullReference exception in the WPF designer on all localization atttributes. When this happens, no localized strings are rendered in the designer.

image

After debugging, I found out the exception is thrown here;
File: NestedMarkupExtension.cs, line 142:

                rootObjectHashCode = rootObject.RootObject.GetHashCode();

rootObject.RootObject == null

It is a bit odd that the next line checks if the RootObject is null, so I'm guessing the RootObject being null is a valid situation:

                rootObjectHashCode = rootObject.RootObject.GetHashCode();

                // We only sign up once to the Window Closed event to clear the listeners list of root object.
                if (rootObject.RootObject != null && !EndpointReachedEvent.ContainsRootObjectHash(rootObjectHashCode))
                {
                    if (rootObject.RootObject is Window window)
                    {
                        window.Closed += delegate (object sender, EventArgs args) { EndpointReachedEvent.ClearListenersForRootObject(rootObjectHashCode); };
                    }

Sorry, I think this issue should actually be in the XAMLMarkupExtensions repo.

Hello

I am facing probably the same issue, but the weirdest thing is that is happen only in one my views in my solution and I can't find a difference with other views where it is working (maybe there is a conflict of some sort, and I am using a custom provider)

I am not an expert of visual studio designer debugging but the closest I got from some information is this exception :
Cannot set unknown member 'Microsoft.VisualStudio.XSurface.Wpf.DT.Visibility

Did someone find a way to avoid having this exception ?

Hi,
I also have this problem that occurs on some of my views without me seeing any explanation. But I noticed that it happens more often when I have overlapping UIElements or when I define design time visibilities.

Hi,
I also have this problem that occurs on some of my views without me seeing any explanation. But I noticed that it happens more often when I have overlapping UIElements or when I define design time visibilities.

Many thanks for your answer I removed the d:Visibility from my view and magically it worked

konne commented

@ruudsieb @alexraoux @ADNALYTICS @Karnah
please check the new 3.8.1-preview1 release. This should solve this issue
Can you please give feedback

@konne thank you very much, it solved the problem for me.