-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ParentWindow is null #30
Comments
Thanks for the hint! This hook was inserted so that the following issue could be solved: #16 The UserControl is currently disposed of via the _ParentWindow.Closed EventHandler. That would no longer be the case and we would have a memory leak. If you have a solution for me to solve your problem, I am happy to implement it! |
I think you had this check before, but removed it for some reason. May I suggest this simple change: |
..and when should |
The Unloaded event will still be called. And even though the _ParentWindow below is null it will not throw an exception (which is surprising to me).
So, Dispose is called in _OnUnloaded. I don't see any down side in checking if the _ParentWindow is null, because if it is the WindowClosed event will never be called anyway... |
Since the method is called recursive, no exception should be thrown here. See: https://github.com/dojo90/NLogViewer/blob/master/src/NLogViewer/Extensions/DependencyObjectExtensions.cs#L20
This logic is needed if you use the Could you please try the following commit whether it solves your problem? 92fb12b |
Ah now I think I get it! 🤦♂️😂 |
yes, that works. Thanks a lot! |
can you please check if the Parentwindow is null ?
If I add the UserControl as an ElementHost child (e.g. in my Outlook Addin) then it'll throw me an exception, because it is not loaded in a Window...
here:
if (_ParentWindow.FindChildByUid(Uid) == null)
and here:
_ParentWindow.Closed += _ParentWindowOnClosed;
Thanks
The text was updated successfully, but these errors were encountered: