JavascriptObjectRepository will not working if a method in a class is paramaterless.
1234567Yang opened this issue · comments
Is there an existing issue for this?
- I have searched both open/closed issues, no issue already exists.
CefSharp Version
newest wpf version
Operating System
Windows 11
Architecture
x86
.Net Version
.NET 6.0
Implementation
WPF
Reproduction Steps
You can do something like this:
BrowserInstance.JavascriptObjectRepository.Settings.LegacyBindingEnabled = true;
BrowserInstance.JavascriptObjectRepository.Register("app",
msgOperation, options: BindingOptions.DefaultBinder);
and in the class
public void sendMsg()
{
ale("NO");
}
public void ale(string msg)
{
MessageBox.Show(msg);
}
When you call ale
through JS, it will work, but when you call sendMsg
through JS, it will show that app.sendMsg
is not a function.
Expected behavior
It will call the function properly
Actual behavior
It will show error.
Regression?
I am not sure.
Known Workarounds
I tested different ways and I found out that a non-paramater method will show error.
Does this problem also occur in the CEF Sample Application
Not Tested
Other information
For the testing above, I do not know how could I test the registration of C# code.
In fact, it seemed that something wrong with the uppercase letter, and I found this issue:
#4683
public void Test(string message)
{
MessageBox.Show(message);
}
public void Test2()
{
MessageBox.Show("e");
}
OR
public void test(string message)
{
MessageBox.Show(message);
}
public void test2()
{
MessageBox.Show("e");
}
but in js, you must call test("")
and test2()
for both of the C# code