Сообщение Re[8]: WebView2 с Proxy от 16.07.2025 13:19
Изменено 16.07.2025 13:22 Passerby
Re[8]: WebView2 с Proxy
Здравствуйте, Passerby, Вы писали:
P>Здравствуйте, bnk, Вы писали:
bnk>>У меня он работает без прокси
P>Кто провайдер?
bnk>>Ну я и говорю, ты уже где-то инициализируешь его до Form_Load (ставишь Source?)
P>Нет, Source не ставлю.
bnk>>Ты сделал как написано выше, по шагам (1, 2)?
P>Сделал снова.
P>Новое приложение Form от Microsoft. Или нужен с FrameWork? Net 9.0.
P>Установил в NuGet WebView2.
P>Дополнил конструктор Form1.
P>К событию Load подсоединил метод Form1_Load(object sender, EventArgs e).
P>Запустил отладку, ошибка на строке await myWebView2.EnsureCoreWebView2Async(env);
P>
P>
P>Здравствуйте, bnk, Вы писали:
bnk>>У меня он работает без прокси
P>Кто провайдер?
bnk>>Ну я и говорю, ты уже где-то инициализируешь его до Form_Load (ставишь Source?)
P>Нет, Source не ставлю.
bnk>>Ты сделал как написано выше, по шагам (1, 2)?
P>Сделал снова.
P>Новое приложение Form от Microsoft. Или нужен с FrameWork? Net 9.0.
P>Установил в NuGet WebView2.
P>Дополнил конструктор Form1.
P>К событию Load подсоединил метод Form1_Load(object sender, EventArgs e).
P>Запустил отладку, ошибка на строке await myWebView2.EnsureCoreWebView2Async(env);
P>
P>using Microsoft.Web.WebView2.Core;
P>//using Microsoft.Web.WebView2.WinForms;
P>namespace WinFormsApp1
P>{
P> public partial class Form1 : Form
P> {
P> //private readonly WebView2 myWebView2 = new WebView2(); уже есть определение
P> public Form1()
P> {
P> InitializeComponent();
P> myWebView2.CreationProperties = null;
P> myWebView2.Location = new Point(10, 65);
P> myWebView2.Name = "myWebView2";
P> myWebView2.Size = new Size(1750, 780);
P> myWebView2.Source = new Uri("https://www.bing.com/", UriKind.Absolute);
P> myWebView2.TabIndex = 0;
P> myWebView2.ZoomFactor = 1D;
P> myWebView2.Visible = true;
P> this.SuspendLayout();
P> ClientSize = new Size(1800, 800);
P> Controls.Add(myWebView2);
P> Name = "Form1";
P> Text = "Form1";
P> ResumeLayout(false);
P> }
P> private async void Form1_Load(object sender, EventArgs e)
P> {
P> CoreWebView2EnvironmentOptions Options = new CoreWebView2EnvironmentOptions();
P> Options.AdditionalBrowserArguments = "--proxy-server=http://1.2.3.4:8888";
P> CoreWebView2Environment env =
P> await CoreWebView2Environment.CreateAsync(null, null, Options);
P> await myWebView2.EnsureCoreWebView2Async(env);
P> }
P> }
P>}
P>P>
P>namespace WinFormsApp1
P>{
P> partial class Form1
P> {
P> /// <summary>
P> /// Required designer variable.
P> /// </summary>
P> private System.ComponentModel.IContainer components = null;
P> /// <summary>
P> /// Clean up any resources being used.
P> /// </summary>
P> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
P> protected override void Dispose(bool disposing)
P> {
P> if (disposing && (components != null))
P> {
P> components.Dispose();
P> }
P> base.Dispose(disposing);
P> }
P> #region Windows Form Designer generated code
P> /// <summary>
P> /// Required method for Designer support - do not modify
P> /// the contents of this method with the code editor.
P> /// </summary>
P> private void InitializeComponent()
P> {
P> myWebView2 = new Microsoft.Web.WebView2.WinForms.WebView2();
P> ((System.ComponentModel.ISupportInitialize)myWebView2).BeginInit();
P> SuspendLayout();
P> //
P> // webView21
P> //
P> myWebView2.AllowExternalDrop = true;
P> myWebView2.CreationProperties = null;
P> myWebView2.DefaultBackgroundColor = Color.White;
P> myWebView2.Location = new Point(12, 52);
P> myWebView2.Name = "webView21";
P> myWebView2.Size = new Size(776, 372);
P> myWebView2.TabIndex = 0;
P> myWebView2.ZoomFactor = 1D;
P> //
P> // Form1
P> //
P> AutoScaleDimensions = new SizeF(7F, 15F);
P> AutoScaleMode = AutoScaleMode.Font;
P> ClientSize = new Size(800, 450);
P> Controls.Add(myWebView2);
P> Name = "Form1";
P> Text = "Form1";
P> Load += Form1_Load;
P> ((System.ComponentModel.ISupportInitialize)myWebView2).EndInit();
P> ResumeLayout(false);
P> }
P> #endregion
P> private Microsoft.Web.WebView2.WinForms.WebView2 myWebView2;
P> }
P>}
P>Re[8]: WebView2 с Proxy
Здравствуйте, Passerby, Вы писали:
P>Здравствуйте, bnk, Вы писали:
bnk>>У меня он работает без прокси
P>Кто провайдер?
bnk>>Ну я и говорю, ты уже где-то инициализируешь его до Form_Load (ставишь Source?)
P>Нет, Source не ставлю.
bnk>>Ты сделал как написано выше, по шагам (1, 2)?
P>Сделал снова.
P>Новое приложение Form от Microsoft. Или нужен с FrameWork? Net 9.0.
P>Установил в NuGet WebView2.
P>Дополнил конструктор Form1.
P>К событию Load подсоединил метод Form1_Load(object sender, EventArgs e).
P>Запустил отладку, ошибка на строке await myWebView2.EnsureCoreWebView2Async(env);
P>
P>
P>Здравствуйте, bnk, Вы писали:
bnk>>У меня он работает без прокси
P>Кто провайдер?
bnk>>Ну я и говорю, ты уже где-то инициализируешь его до Form_Load (ставишь Source?)
P>Нет, Source не ставлю.
bnk>>Ты сделал как написано выше, по шагам (1, 2)?
P>Сделал снова.
P>Новое приложение Form от Microsoft. Или нужен с FrameWork? Net 9.0.
P>Установил в NuGet WebView2.
P>Дополнил конструктор Form1.
P>К событию Load подсоединил метод Form1_Load(object sender, EventArgs e).
P>Запустил отладку, ошибка на строке await myWebView2.EnsureCoreWebView2Async(env);
P>
P>using Microsoft.Web.WebView2.Core;
P>//using Microsoft.Web.WebView2.WinForms;
P>namespace WinFormsApp1
P>{
P> public partial class Form1 : Form
P> {
P> //private readonly WebView2 myWebView2 = new WebView2(); уже есть определение
P> public Form1()
P> {
P> InitializeComponent();
P> myWebView2.CreationProperties = null;
P> myWebView2.Location = new Point(10, 65);
P> myWebView2.Name = "myWebView2";
P> myWebView2.Size = new Size(1750, 780);
P> myWebView2.Source = new Uri("https://www.bing.com/", UriKind.Absolute);
P> myWebView2.TabIndex = 0;
P> myWebView2.ZoomFactor = 1D;
P> myWebView2.Visible = true;
P> this.SuspendLayout();
P> ClientSize = new Size(1800, 800);
P> Controls.Add(myWebView2);
P> Name = "Form1";
P> Text = "Form1";
P> ResumeLayout(false);
P> }
P> private async void Form1_Load(object sender, EventArgs e)
P> {
P> CoreWebView2EnvironmentOptions Options = new CoreWebView2EnvironmentOptions();
P> Options.AdditionalBrowserArguments = "--proxy-server=http://1.2.3.4:8888";
P> CoreWebView2Environment env =
P> await CoreWebView2Environment.CreateAsync(null, null, Options);
P> await myWebView2.EnsureCoreWebView2Async(env);
P> }
P> }
P>}
P>P>
P>namespace WinFormsApp1
P>{
P> partial class Form1
P> {
P> /// <summary>
P> /// Required designer variable.
P> /// </summary>
P> private System.ComponentModel.IContainer components = null;
P> /// <summary>
P> /// Clean up any resources being used.
P> /// </summary>
P> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
P> protected override void Dispose(bool disposing)
P> {
P> if (disposing && (components != null))
P> {
P> components.Dispose();
P> }
P> base.Dispose(disposing);
P> }
P> #region Windows Form Designer generated code
P> /// <summary>
P> /// Required method for Designer support - do not modify
P> /// the contents of this method with the code editor.
P> /// </summary>
P> private void InitializeComponent()
P> {
P> myWebView2 = new Microsoft.Web.WebView2.WinForms.WebView2();
P> ((System.ComponentModel.ISupportInitialize)myWebView2).BeginInit();
P> SuspendLayout();
P> //
P> // webView21
P> //
P> myWebView2.AllowExternalDrop = true;
P> myWebView2.CreationProperties = null;
P> myWebView2.DefaultBackgroundColor = Color.White;
P> myWebView2.Location = new Point(12, 52);
P> myWebView2.Name = "myWebView2";
P> myWebView2.Size = new Size(776, 372);
P> myWebView2.TabIndex = 0;
P> myWebView2.ZoomFactor = 1D;
P> //
P> // Form1
P> //
P> AutoScaleDimensions = new SizeF(7F, 15F);
P> AutoScaleMode = AutoScaleMode.Font;
P> ClientSize = new Size(800, 450);
P> Controls.Add(myWebView2);
P> Name = "Form1";
P> Text = "Form1";
P> Load += Form1_Load;
P> ((System.ComponentModel.ISupportInitialize)myWebView2).EndInit();
P> ResumeLayout(false);
P> }
P> #endregion
P> private Microsoft.Web.WebView2.WinForms.WebView2 myWebView2;
P> }
P>}
P>