-
Notifications
You must be signed in to change notification settings - Fork 51
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
Element not found. (0x80070490) when using host objects #335
Comments
Thanks for bringing this to our attention! I've filed a bug and we will investigate. |
@fvanheeswijk Has this error only hit once and typically the code works fine? Or does it fail in some environment, for example, and you are unable to reproduce the issue locally? |
@champnic This issue reproduces 100% of the time in our actual application and also for multiple developers, the only thing we cannot get it to do is to reproduce within a test project. |
I just found this topic on Stackoverflow: https://stackoverflow.com/a/62804535 Is this still the case? Our class is marked with |
We have a task to improve our documentation here for .NET. We looked into this issue a bit and we don't think it's related to your host object - rather the JS garbage collector at some point decides to clean up the host object which removes it on the host side as well, and so calling the host object function results in the element not found error. As noted, the workaround is to always use the full We're going to keep digging and see if we can fix the GC issue with the host objects. |
Here's some documentation regarding COM that you may find useful: |
Hi Everyone, This was addressed in the 1.0.707-prerelease version. |
I'm still seeing this on 1.0.721-prerelease. Using the full window.chrome.webview.hostObjects.sync. to access my object resolves it so I'm pretty sure it's the same issue. |
@fvanheeswijk,@champnic I did some testing and I think that I may have found the issue when using the code posted above (which I'm re-posting below):
The issue occurs at this statement: Original:
Change To:
Result: The most likely cause is trying to run the code above using Here's a solution that seems to work: For the JavaScript don't use The code below can also be found in the .zip file at the end of this post. I've included the entire code below, for anyone reading this who may be reluctant to open a project from an unknown source. Note: For
Create a JavaScript file named: JavaScript1.js JavaScript1.js
Create a class named: ExternalDocHostUICallback.cs ExternalDocHostUICallback.cs
Create a class named: HelperLoadResource.cs HelperLoadResource.cs
Create a form named: FrmMain.cs FrmMain.Designer.cs
FrmMain.cs
Here are 2 demo projects. One that doesn't work, and one that works. To use the demo projects ensure that
WebView2HostObjectsTest - doesn't work.zip WebView2HostObjectsTest - works.zip Resources |
So this issue will be more difficult to debug as we so far have not been able to reproduce it.
When we call
$WF.handler.systemIdentification()
we get the following error:However
window.chrome.webview.hostObjects.sync.handler.systemIdentification()
works correctly with no issues.Furthermore,
$WF.handler
is defined as follows:systemIdentification
is defined as follows:And later on we add an event to it, but that shouldn't be an issue.
We also get different error messages when we either call a different (non-existent) function or we pass an invalid number of parameters, so it should be the correct function/method we are calling.
We have tried to reproduce this issue but have not been successful in a test project, can you give us any hints on how to continue debugging this? We are particularly surprised by the fact that
window.chrome.webview.hostObjects.sync.handler.systemIdentification()
works but$WF.handler.systemIdentification()
does not and this appears to be one of the only functions/methods that is not working, other ones that we are using do work.AB#27803563
The text was updated successfully, but these errors were encountered: