Home

DumpPanel from Task gives exception

edited January 8

Base test code

This is a follow-up to previous efforts to dump output to new panels. With that in mind, I've tried to enhance the code for use in multi-thread environments (my ultimate use case scenario). Calling this code the first time things work as expected. LINQPad shifts focus to the new output panel. Everything displays as expected when it's expected to do so.

Running the code a second time I get an exception reported, but nothing concrete to track down specifically where it's happening. The Output panel is empty of any content. The specified output panel still contains the output (and at the timing indicated by the test code), but LINQPad does not swap over to it. Looking for insight on what I need to change.

I totally get I'm attempting to use a disposed component. I'm not sure why it's attempting to use a disposed component. Is this a case of the "old" output panel isn't cleaned up prior to attempting to use it on the second run? Closing the output panel manually doesn't result in this exception and seems to suggest this is the case.

Comments

  • Not really a solution but can you try an older version of WebView2.
    Your script works for me using version 1.0.2151.40 but goes wrong with the latest version.

  • Hmm. Yeah. I don't get the exception with the older version. Just seems odd that manually clearing away the old output panel eliminates the exception as well.

  • I am beginning to think this is just a simple bug in the dispose method of WebView2 and not really related to running in multi-thread environments.

    The first time through your script creates a WebView2 which is still visible and hence active after your script completes. So the second time through, the first thing LinqPad needs to do is dispose of the old panel and hence the webview2 object is also disposed.

    The dispose method attempts to remove an event from the profile but accessing the profile throws this InvalidOperationException exception. The previous version of the nuget package caught all exceptions around this code, but the latest version just catches NotImplementedException and hence this exception is shown.

    See https://github.com/MicrosoftEdge/WebView2Feedback/issues/4272

    So I think reverting to 1.0.2151.40 until they fix the issue should be OK.

    Just seems odd that manually clearing away the old output panel eliminates the exception as well.

    Not sure why. Perhaps LinqPad catches and hides exceptions in that case.

Sign In or Register to comment.