LoginSignup
1
5

More than 5 years have passed since last update.

WPFアプリケーション上のWebBrowserでreactjs等が動かない場合の対処

Last updated at Posted at 2017-06-09

理由

内部で使用されているIEのエンジンが古い

対処方法

Chromeを使用するようにする(推奨)

the open source version of Google Chrome
https://cefsharp.github.io/

これを使用することで何でもありな状態にもっていけます。
(IEとかWindowsのバージョンとか気にしなくてよくなる)

meta情報をWebPage側に追加する

<meta http-equiv="X-UA-Compatible" content="IE=10">

のようにブラウザーの指定を入れる

<head>
    <meta http-equiv="X-UA-Compatible" content="IE=10">
    <title>Wpf Webview</title>
</head>

おまけ

スクリプトエラーを抑制したい場合

var axIWebBrowser2 = typeof(WebBrowser).GetProperty("AxIWebBrowser2", BindingFlags.Instance | BindingFlags.NonPublic);
var comObj = axIWebBrowser2.GetValue(webview, null);
comObj.GetType().InvokeMember("Silent", BindingFlags.SetProperty, null, comObj, new object[] { true });

InitializeComponent以降のどこかで設定をする
上記でwebviewとなっている所をWebBrowserに付けたNameで置き換える

1
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
5