KeldorKatarn
Topic Author
Posts: 193
Joined: 30 May 2014, 10:26

NullReferenceException whenever XAML is reloaded

26 Apr 2021, 19:23

I have a minor issue in Unity.
Whenever I make changes to a XAML and then go back to the Unity Editor and it reloads it, I can the "save asset" dialog and when I confirm I get this in the console:
[Exception] NullReferenceException: Object reference not set to an instance of an object
ContainerWindow.NotDockedWindowID() at <d3ff43e972b043d1b3f49905ec5da738>:0

ContainerWindow.Load() at <d3ff43e972b043d1b3f49905ec5da738>:0

ContainerWindow.Show() at <d3ff43e972b043d1b3f49905ec5da738>:0

EditorWindow.ShowWithMode() at <d3ff43e972b043d1b3f49905ec5da738>:0

EditorWindow.ShowModal() at <d3ff43e972b043d1b3f49905ec5da738>:0

AssetSaveDialog.ShowWindow() at <d3ff43e972b043d1b3f49905ec5da738>:0

AssetModificationProcessorInternal.OnWillSaveAssets() at <d3ff43e972b043d1b3f49905ec5da738>:0

NoesisPostprocessor.ImportXaml() at /NoesisGUI/Plugins/Editor/NoesisPostprocessor.cs:369
368:       EditorUtility.SetDirty(xaml);
-->369:       AssetDatabase.SaveAssets();
370:       Log("? ImportXaml");
371:   }

NoesisPostprocessor.ImportXaml() at /NoesisGUI/Plugins/Editor/NoesisPostprocessor.cs:316
314:   {
315:       bool changed;
-->316:       return ImportXaml(filename, reimport, reload, out changed);
317:   }

NoesisPostprocessor.ImportAssets() at /NoesisGUI/Plugins/Editor/NoesisPostprocessor.cs:79
77:       else if (IsXaml(asset))
78:       {
-->79:           ImportXaml(asset, true, reload);
80:       }
81:   }

<>c__DisplayClass4_1.<OnPostprocessAllAssets>b__0() at /NoesisGUI/Plugins/Editor/NoesisPostprocessor.cs:111
110:   string[] assets = importedAssets.Concat(movedAssets).ToArray();
-->111:   ImportAssets(assets,  NoesisSettings.Get().hotReloading, (progress, asset) =>
112:       EditorUtility.DisplayProgressBar("Import XAMLs", asset, progress));
113:   EditorUtility.ClearProgressBar();

This happens every single time a XAML is reloaded

Edit: Just to be clear this doesn't cause any further issues than the logged exception. The xaml is reloaded perfectly fine. It seems Noesis is trying to open some sort of editor window and not finding it?

Tags:
 
User avatar
sfernandez
Site Admin
Posts: 2220
Joined: 22 Dec 2011, 19:20

Re: NullReferenceException whenever XAML is reloaded

27 Apr 2021, 20:23

From the callstack I will say is the AssetDatabase.SaveAssets() call and Unity trying to open a modal window which is throwing the exception.
I don't know if we can do anything about it, maybe delay the call to SaveAssets. We'll try to reproduce it and see if we can avoid it, thanks for pointing this out.
 
User avatar
sfernandez
Site Admin
Posts: 2220
Joined: 22 Dec 2011, 19:20

Re: NullReferenceException whenever XAML is reloaded

27 Apr 2021, 20:25

One question, is Unity playing when you get that error, or is it always happening?
 
KeldorKatarn
Topic Author
Posts: 193
Joined: 30 May 2014, 10:26

Re: NullReferenceException whenever XAML is reloaded

27 Apr 2021, 20:37

It is always happening. And yes once I edited a XAML in Visual Studio and come back to Unity, Unity opens the "save asset" dialog. once I click save, the exception is thrown. Not sure what Unity is trying to open there.
 
User avatar
sfernandez
Site Admin
Posts: 2220
Joined: 22 Dec 2011, 19:20

Re: NullReferenceException whenever XAML is reloaded

27 Apr 2021, 20:44

I don't get the chance to see any dialog poping and I don't remember ever seeing a dialog that I had to click "Save" for saving an asset.
Which Unity version are you using, so we can try the same thing?
 
KeldorKatarn
Topic Author
Posts: 193
Joined: 30 May 2014, 10:26

Re: NullReferenceException whenever XAML is reloaded

27 Apr 2021, 21:29

Unity 2019.4.9f1 (64-bit) at the moment.
This is what I get:
screenshot.jpg
As soon as I hit "Save all", the exception is thrown.
 
KeldorKatarn
Topic Author
Posts: 193
Joined: 30 May 2014, 10:26

Re: NullReferenceException whenever XAML is reloaded

28 Apr 2021, 03:17

Found it. Apprently a Unity bug in this version:

https://forum.unity.com/threads/2019-3- ... on.891469/

Deactivating that verify option should also stop displaying that dialog for me (which is incredibly annoying when Noesis initially loads all its included XAMLs because that dialog opens for every single XAML asset individually.... sigh. Sometimes Unity devs do weird things.
 
User avatar
jsantos
Site Admin
Posts: 3122
Joined: 20 Jan 2012, 17:18
Contact:

Re: NullReferenceException whenever XAML is reloaded

28 Apr 2021, 11:42

Thanks for this. The message is in fact disturbing

"Unity is about to save the following modified files. Unsaved changes will be lost"

Glad to know it is a bug in Unity.
 
KeldorKatarn
Topic Author
Posts: 193
Joined: 30 May 2014, 10:26

Re: NullReferenceException whenever XAML is reloaded

28 Apr 2021, 17:54

I'm actually assuming it's fixed in later versions. I had to pause my project for a while and I haven't upgraded to the 2020 versions yet. I'll confirm once I do that this is no longer an issue.

Who is online

Users browsing this forum: No registered users and 4 guests