Imports System.IO Imports System.Threading.Tasks Imports Microsoft.Web.WebView2.Core Public Class Frm_WebManual Public Sub Navigate(url As String) Try If WebView21 IsNot Nothing AndAlso WebView21.CoreWebView2 IsNot Nothing Then WebView21.CoreWebView2.Navigate(url) End If Catch ex As Exception MessageBox.Show("웹페이지 이동 중 오류가 발생했습니다: " & ex.Message, "오류", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub Private Async Sub Frm_WebManual_Load(sender As Object, e As EventArgs) Handles MyBase.Load Try ' WebView2 초기화 (Runtime이 없으면 자동 다운로드) Await InitializeWebView2Async() ' 로컬 웹서버 페이지 로드 If WebView21.CoreWebView2 IsNot Nothing Then WebView21.CoreWebView2.Navigate("http://localhost:58123/") End If Catch ex As Exception MessageBox.Show("웹페이지 로드 중 오류가 발생했습니다: " & ex.Message, "오류", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub Private Async Function InitializeWebView2Async() As Task Try ' Fixed Version 경로 설정 Dim fixedVersionPath = Path.Combine(Application.StartupPath, "WebView2Runtime") Dim userDataFolder = Path.Combine(Application.StartupPath, "WebView2Data") ' Fixed Version이 있는지 확인 If Directory.Exists(fixedVersionPath) Then ' Fixed Version 사용 Dim env = Await CoreWebView2Environment.CreateAsync(fixedVersionPath, userDataFolder) Await WebView21.EnsureCoreWebView2Async(env) Else ' 시스템에 설치된 Runtime 사용 (폴백) Await WebView21.EnsureCoreWebView2Async(Nothing) End If Catch ex As Exception ' WebView2 Runtime을 찾을 수 없는 경우 MessageBox.Show( "WebView2 구성 요소를 찾을 수 없습니다." & vbCrLf & vbCrLf & "프로그램 설치가 올바르지 않을 수 있습니다." & vbCrLf & "관리자에게 문의하시기 바랍니다.", "오류", MessageBoxButtons.OK, MessageBoxIcon.Error) Me.Close() End Try End Function End Class