0

I found one thing in javascript of my WPF project. It has called

window.external.ShowWindow();

I have found that method is written in class InteropClass like below.

[ComVisible(true)]
public class InteropClass
{
    public void ShowWindow()
    {
        // logic
    }
}

and that method is called. I am trying to analyse it, for that I have used already built class like below

[ComVisible(true)]
public partial class AnotherClass : SomeDifferentClass
{
    public void AnotherMethod()
    {
        // logic
    }
}

and tried to call it as

window.external.AnotherMethod();

but it is not working. Error alert says

AnotherMethod is not supported by window.external object

I know both classes differs in many terms and I can make it work but my question is What rules to be followed to make this work, may be like class must be directly inherited from Object or some other.

Imad
  • 7,126
  • 12
  • 55
  • 112

1 Answers1

0

What you need to do is set the ObjectForScripting property on the web browser control to an object containing the C# methods you want to call from JavaScript.

from here told me everything I was missing.

Community
  • 1
  • 1
Imad
  • 7,126
  • 12
  • 55
  • 112