-
Notifications
You must be signed in to change notification settings - Fork 53
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
AddHostObjectToScript() results in exception #3680
Comments
I had this problem too, but I finally solved it, this is my problem var libraryHelper = new LibraryHelper();
webView.CoreWebView2.AddHostObjectToScript("LibraryHelper", libraryHelper); //System.ArgumentException:“Value does not fall within the expected range.” Version I found the cause of the exception. My "LibraryHelper" class forgot to add modifier. After adding the "Public" modifier, everything was normal. Modify To |
@sq800 Thanks for trying, but unfortunately, that didn't change anything for me. |
Hmm, some more experimenting and upgrading There seems to be a problem with optional parameters. They get filled in correctly, but I get a
But the value still gets returned to the webview. At least simple values. |
Edit: some mistakes on my part yesterday, other than objects as parameters or call-result, things seem to be working now. |
@ray007 I would close this issue if it's not an issue? |
Did I miss something about parameters of type |
i have a same exception. i don't know why the IsAsyncMethod called. How did you solve this exception |
@jMWCQQQ1 make sure it's declard as #pragma warning disable CS0618
[ClassInterface(ClassInterfaceType.AutoDual)]
#pragma warning restore CS0618
[ComVisible(true)] I think that's all I did to make it work back then... |
I have already done these same things, but still report errors。but thanks |
Description
I'm calling
and get an exception:
System.ArgumentException: "Value does not fall within the expected range."
Stacktrace into webview:
Version
SDK: 1.0.1901.177
Runtime: 115.0.1901.183
Framework: WPF with .NET 4.7.2
OS: Win10
Regression
Was this working before but has regressed?
Unknown since I had no old version.
Additional context
The
Bridge
class is defined with attributesis there something else I need to do take make the
Bridge
usable as host object?The text was updated successfully, but these errors were encountered: