Use random user data folder to prevent error 0x8007139F "Expecting object to be local"#4
Draft
mrautio wants to merge 3 commits intopandrr:mainfrom
Draft
Use random user data folder to prevent error 0x8007139F "Expecting object to be local"#4mrautio wants to merge 3 commits intopandrr:mainfrom
mrautio wants to merge 3 commits intopandrr:mainfrom
Conversation
62e7ff7 to
28fec48
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR addresses a COM exception (0x8007139F "Expecting object to be local") that occurs when multiple Windows programs utilize WebView2 by isolating the WebView2 user data folder. The solution creates a unique temporary folder for each instance and adds proper cleanup on application exit.
- Create unique user data folder using random filename to prevent conflicts
- Add window closing event handler to ensure proper cleanup
- Implement cleanup logic to remove temporary folder and terminate WebView2 process
28fec48 to
fe64c3f
Compare
WebView2 process is shared per associated user data folder. if there is another program using same user data folder then it's possible that demo throws exception: and fails to run.
fe64c3f to
fdd64f2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If there are unrelated Windows programs that utilize WebView2, starting of demo may result in
System.Runtime.InteropServices.COMException (0x8007139F): Expecting object to be localerror since WebDemo.exe tries to use pre-existing WebView2 process. This Pull Request places WebView2 user data folder under a random temp folder preventing the issue from occurring.WebView2 process describes shared user data folder behavior: https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/process-model?tabs=csharp