0

I am getting this error when running my code.

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: ''System.MarshalByRefObject.InvokeMember(string, System.Reflection.BindingFlags, System.Reflection.Binder, object[], System.Reflection.ParameterModifier[], System.Globalization.CultureInfo, string[])' is inaccessible due to its protection level'

I see that when clicking the button it is finding the correct button name but it is not clicking it. Below is my full code.

//LOGIN 
    private void Login_Click(object sender, RoutedEventArgs e)
    {
        dynamic d = wb.Document;
        var el = d.GetElementsByTagName("input");
        var button = d.GetElementsByTagName("button");

        d.GetElementsByname("login")[0].value = this.NameBox.Text;
        d.GetElementsByName("password")[0].value = this.PWBox.Text;
        d.GetElementsByname("save")[0].InvokeMember("login");enter code here

    }

This is the button code

<buttons>
        <button name="save" class="k-btn-dark" type="submit">Login</button>

The Password and Username fields generate correctly but I get the "inaccessible" error on button click.

Kzryzstof
  • 7,688
  • 10
  • 61
  • 108
Keith
  • 11
  • 4

2 Answers2

0

Isn't it a problem of class accessibility ? or function ?

Look at this post which talks about Resources but it could be the same for your case: 'Resource' is inaccessible due to its protection level

Val
  • 33
  • 7
  • I think you are correct because if I change InvokeMember ("submit") to ("Click") I am getting the same error. So it is not finding the button it is hitting the exception before firing. How would I fix this though? I cant seem to find the "Access Modifier" option that post was talking about. – Keith Aug 30 '18 at 17:27
0

I GOT IT!

d.GetElementsByName("save")[0].Click();

No need for the InvokeMember.

Keith
  • 11
  • 4