0

So I developed an vb.net app with webview2. My problem is: if I copy the entire debug folder to a new computer, It works. But if I create an installer with the entire debug folder, it does not work. Any idea?

I'm using the stable package from NuGet.

When I copied and pasted the files I didn't even need to bother with installing the evergreen release and it worked.

  • You shouldn't be doing anything with the entire Debug folder. That's for debugging. The Release folder is where you deploy from. You should be changing the build configuration and building and releasing the output of that. – jmcilhinney Mar 04 '21 at 07:35
  • I've not use WebView2 but I assume that it would work the same way as any other library, which means that you should be able to open the References page of the project properties and set the Copy Local property of the relevant reference(s) to True. That library(ies) will then be copied to the output folder with your EXE. – jmcilhinney Mar 04 '21 at 07:36
  • I just tested and after adding v1.0.705.50 of the Microsoft.Web.WebView2 package, three WebView2 references were added and Copy Local was True for all of them by default. When I built the project, all three DLLs were copied to the output folder. Are you seeing the same thing? – jmcilhinney Mar 04 '21 at 09:18

3 Answers3

1

Are you using the default user data folder and are you installing to Program Files? If so, you may need to explicitly specify your user data folder to an app data folder for your application. Read more about Managing user data folders in the WebView2 documentation.

The default user data folder is the path of the host app executable with ".WebView2" appended to the end. So notepad's default would be "C:\windows\system32\notepad.exe.webview2". This doesn't work when the path containing the host executable doesn't have permissions to allow the host app to create the user data folder. Most installers run elevated and have additional permissions to create the application's installed files and folders. But when the installed app runs it generally doesn't have permission to modify the contents of its install path. Instead you should explicitly specify a user data folder and manage that folder including potentially deleting it when your app is uninstalled.

David Risney
  • 3,886
  • 15
  • 16
0
Public Sub New()
    Dim url As String = Nothing
    InitializeComponent()
    InitializeBrowser(url)
End Sub

Private Async Sub InitializeBrowser(ByVal Optional url As String = Nothing)
    Dim userDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\SoftwareName"
    Dim env = Await CoreWebView2Environment.CreateAsync(Nothing, userDataFolder)
    Await WebView21.EnsureCoreWebView2Async(env)
    WebView21.Source = New Uri("https://www.google.com/")
End Sub
Shankar
  • 9
  • 1
  • Welcome to Stack Overflow. What is the question here? What is meant by "distribute" in this context? Please provide some sort of overview of what you're trying to accomplish, and what you have done to solve it or what challenges you've faced. – Dennis Mar 05 '21 at 21:04
0

Maybe this can be your solution: On March 14th, Microsoft began auto-installing the 'Microsoft Edge WebView2 Runtime' on Windows 10 machines without any notification to users.

Source: https://www.bleepingcomputer.com/news/microsoft/microsoft-is-auto-installing-the-windows-10-webview2-runtime/

GrooverFromHolland
  • 971
  • 1
  • 11
  • 18