Skip to content

Problem with parameters when calling bound function from js #1673

@ray007

Description

@ray007

There seems to be a problem with managing missing/optional parameters.
in JavascriptObjectRepository.cs line 123 my null-Parameter from javascript gets matched in replaced by a MissingParameter.

i.e. C#:

public void setData(string data1, string data2 = null) { ... }

The failing call in javascript looks like this:

window.cef.setData(null);

Resulting Exception:

System.InvalidOperationException occurred
  HResult=-2146233079
  Message=Could not execute method: showLWebPage(System.Reflection.Missing, System.Reflection.Missing) - Missing Parameters: 1
  Source=CefSharp
  StackTrace:
       at CefSharp.Internals.JavascriptObjectRepository.TryCallMethod(Int64 objectId, String name, Object[] parameters, Object& result, String& exception)
  InnerException: System.ArgumentException
       HResult=-2147024809
       Message=Missing parameter does not have a default value.
Parameter name: parameters
       Source=mscorlib
       ParamName=parameters
       StackTrace:
            at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
            at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
            at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
            at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
            at CefSharp.Internals.JavascriptObjectRepository.TryCallMethod(Int64 objectId, String name, Object[] parameters, Object& result, String& exception)
       InnerException: 

The problem was introduced by #1644

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions