0

Forgive my formatting, as this is my first post. I have been working with a legacy app, and they added a new UI. This is just a POC to show we can make a thin client, and host our project online.

I have a WPF window (.NET Framework 4.7.2), with a WebBrowser user control. My website has a button tied to window.external['HelloWorld']('Hello') (as seen below)

When debugging locally, the interactions happen as planned, but when deployed. My local WPF app does not receive anything from the hosted website. Both local and deployed sites are HTTPS

Pointing to a static HTML website with <script> tags does work as well.

C# (WPF Class)

public partial class TestWindow : Window
    {
        public TestWindow()
        {
            InitializeComponent();
            
            webBrowser.Navigate(//insert Angular URL here);
            webBrowser.Loaded += webBrowser_Loaded;
        }
        
        void webBrowser_Loaded(object sender, RoutedEventArgs e)
        {
            webBrowser.ObjectForScripting = new ScriptingHelper();
        }
    }

C# (Script Object)

[ComVisible(true)]
public class ScriptingHelper
{
        public void HelloWorld(string text)
        {
                MessageBox.Show(text);
        }
}

TypeScript

onButtonClicked() {
        if (window.external && typeof window.external['HelloWorld'] !== 'undefined') {
                const helloText = "Hello from website";
                window.external['HelloWorld'](hellotext);
        }
}

1 Answers1

0

Turns out my syntax for window.external was incorrect. While window.external'comVisibleFunctionname' worked locally, the synax is (window.external as any).HelloWorld(). It argues with my linter but that is due to depreciation I believe