Open oconnor663 opened 12 years ago
Good find, will take a look throwing an exception for this case.
Not clear on what you mean by "that object" and "the function". Can you clarify of post a small code example?
Sure, I should've done that from the beginning:
/*
* Instantiate a WebView and register a simple JS object
*/
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
CEF.RegisterJsObject("test", new Test());
WebView v = new WebView(
@"C:\Users\jacko\Desktop\test.html",
new CefSharp.BrowserSettings());
v.Parent = this;
v.Dock = DockStyle.Fill;
}
}
class Test
{
public int returnThree()
{
return 3;
}
}
<!-- test.html: This causes the app to crash! -->
<html><body><script>
var regularObject = {};
// bind the native method to the JS object
regularObject.returnThree = test.returnThree;
// call it from the JS object
regularObject.returnThree();
// CRASH!!!
</script></body></html>
I did the following by accident:
This is obviously unsupported behavior, but it probably should just cause a JS error, instead of crashing the whole app. Here's the exception.
System.NullReferenceException was unhandled Message: Object reference not set to an instance of an object.