msi with C#-webview2 does not work with webview

huangapple go评论63阅读模式
英文:

msi with C#-webview2 does not work with webview

问题

using System;
using System.Windows.Forms;

namespace Test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            Load += Form1_Load;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.webView21.Source = new Uri("https://www.google.com");
        }
    }
}
我是一名刚开始学习C#的学生。
如果您按照上面的代码编写并使用ClickOnce发布,
WebView将正常工作。
然而,如果您将其制作为MSI文件,WebView将无法正常工作。
您能帮助我了解需要采取哪些措施吗?
英文:
using System;
using System.Windows.Forms;


namespace Test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
             Load += Form1_Load;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.webView21.Source = new Uri("https://www.google.com");
        }
    }
}

I am a student just starting to learn C#.
If you simply write the code as above and publish it with (Clickonce) publish,
the webview will work normally.
However, if you make it as an msi file, the webview does not work.
Can you help me with what needs to be done?

答案1

得分: 0

A common cause is the WebView2Loader.dll not being included.

Sometimes it needs to be manually included.

See Distribute your app and the WebView2 Runtime - Files to ship with the app

Also see these discussions of the issue...

Deployed C# app using WebView2 cannot find the Runtime

WebView2Loader.dll is left out when publishing

WebView2Loader.dll is missing from the Installer Folder

WebView2 works in debug but not when published with ClickOnce

英文:

A common cause is the WebView2Loader.dll not being included.

Sometimes it needs to be manually included.

See Distribute your app and the WebView2 Runtime - Files to ship with the app

Also see these discussions of the issue...

Deployed C# app using WebView2 cannot find the Runtime

WebView2Loader.dll is left out when publishing

WebView2Loader.dll is missing from the Installer Folder

WebView2 works in debug but not when published with ClickOnce

huangapple
  • 本文由 发表于 2023年3月31日 16:11:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/75896249.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定