UWP Webview 2 WebViewContainer.CoreWebView2.AddHostObjectToScript without C++ WinRT Component

Vishy 0 Reputation points

Hello All,

I have a UWP application where I am using WebView 2 Controls to host the websites.

Now when I need to connect between Js and my C# code all are saying to use the WinRT C++ adapter wrapper.

var dispatchAdapter = new WinRTAdapter.DispatchAdapter(); WebViewContainer.CoreWebView2.AddHostObjectToScript("external", dispatchAdapter.WrapObject(App.MessageCallWrapper, dispatchAdapter));


Is is necessary to use the WinRT C++ adapter project in UWP, without that I get error every-time and using it I am able to access the C# class from JS script.



Universal Windows Platform (UWP)
{count} votes