Today, out of nowhere my program suddenly ran into "couldn't initialize Webview2 binding" on startup.
The problem remains after I tried rebooting my pc, recompliling the exe,
reinstalling webview2 runtime, running in the IDE, or reresgistering RC6 binaries.
Cannot reproduce the behaviour on my machine -
but nevertheless have uploaded a new RC6-BaseLibs-package -
which now contains the newest version of the MS 'WebView2Loader.dll' -
as well as a slightly changed BindTo-Method, which deals more thouroughly with "compatible-versions"...
Please check it out after downloading the new package (with all Dlls) -
and re-registering RC6.dll
@Bob17
This might help also in your case - though not sure (it's still a "shot into the blue" -
because - as said - cannot reproduce the behaviour).
What helped me in this regard (in the early phases of developing it) was,
to delete the "UserFolder" completely (in case you gave it a specific location) -
or to change the location to a different UserFolder-Path with "full write-rights, and nothing else in it".
Hi Olaf,
Calling a vb6 COM dll that has RC6 WebView2 from a .NET application crashes the process (on calling BindTo method) with heap corruption error in ntdll.dll. This is reproducible, I have attached sample code with one c# forms project and one vb6 dll project. Could you please take a look and give some comments on it, maybe you can pinpoint the cause. Thanks!
Hi Olaf,
Calling a vb6 COM dll that has RC6 WebView2 from a .NET application crashes the process...
I'm aware of that problem -
and .NET-compiled (32Bit-x86) Host-Processes are not the only ones who cause it...
There's also VBA (when run from within 32Bit Excel or Access.exe Processes) which has that problem.
I have currently not investigated this deeply - but my assumption is,
that a VB6-compiled 32Bit Host-Exe is initializing the vb6-runtime-dll differently on startup -
(compared to an "isolatedly loaded" VB6-COM-Dll - like the RC6 on different "Host-Exes").
In case of a VB6-compiled Host-exe the RC6-Dll "meets an already initialized vb6-runtime" (on the MainThread) -
and in case of differently compiled Host-exes, the RC6-Dll "has to initialize the vb6-runtime itself".
There is all sorts of other (threading-related things) to consider along with that -
it might be that the hosting Executables where it fails, have initialized their COM(Threads) to "MTA-mode" and not "STA-Mode".
I hesitate to invest much of my time into it - because TwinBasic offers a WebView2-Binding as well (also for VBA).
And ".NETers" have also their own "WebView2-Binding" available in a .NET-based Class-wrapper.
Is there a reason, why you want to use (32Bit only!)-VB6-compiled-COM-Dlls in a .NET-App?
Well, I need to support such scenario where web browsing is in the COM dll and the caller is arbitrary application, possibly .NET-based. One interesting detail, if .NET app is based on Framework 3.5 or 4 then the app is not crashing!
Well, I need to support such scenario where web browsing is in the COM dll and the caller is arbitrary application, possibly .NET-based. One interesting detail, if .NET app is based on Framework 3.5 or 4 then the app is not crashing!
A VB6-Host-Exe might help (which encapsulates the whole thing - including the VB6-Form you "BindTo").
You can even make this VB6-Executable an ActiveX-Exe-Project -
with your current "Dll-based Public COM-Class" exposed as a Public Class of the AciveX-Exe -
which is BTW one of the few ways, to make a VB6-Class "consumable" also by 64Bit-Host-Processes.
(remember, you cannot load a VB6-compiled 32Bit COM-Dll into a 64Bit-Process directly -
only Cross-Process-COM-calls between 64Bit-Consumer-Process and a 32Bit-ClassHost-Process allow that feat)
I'm aware of that problem -
and .NET-compiled (32Bit-x86) Host-Processes are not the only ones who cause it...
There's also VBA (when run from within 32Bit Excel or Access.exe Processes) which has that problem.
I have currently not investigated this deeply - but my assumption is,
that a VB6-compiled 32Bit Host-Exe is initializing the vb6-runtime-dll differently on startup -
(compared to an "isolatedly loaded" VB6-COM-Dll - like the RC6 on different "Host-Exes").
In case of a VB6-compiled Host-exe the RC6-Dll "meets an already initialized vb6-runtime" (on the MainThread) -
and in case of differently compiled Host-exes, the RC6-Dll "has to initialize the vb6-runtime itself".
There is all sorts of other (threading-related things) to consider along with that -
it might be that the hosting Executables where it fails, have initialized their COM(Threads) to "MTA-mode" and not "STA-Mode".
I hesitate to invest much of my time into it - because TwinBasic offers a WebView2-Binding as well (also for VBA).
And ".NETers" have also their own "WebView2-Binding" available in a .NET-based Class-wrapper.
Is there a reason, why you want to use (32Bit only!)-VB6-compiled-COM-Dlls in a .NET-App?
Olaf
Hello Olaf. You are right. By creating an ActiveX-Exe and exposing a cWebView2 wrapper as a public class of the ActiveX-exe I can use WebView2 in my PowerBuilder application without problems (something that directly using RC6 I have not achieved). Not ideal, but at least I have a choice.
Hi,
I have the same problem as Resurrected.
So Resurrected seems to solve with 'Microsoft.WebView2.FixedVersionRuntime.107.0.1418.62.x64' but i have not found the installer of this version.
Microsoft publish the latest version only.
Anybody can help me ?
Win10 has direct support for unpacking of *.cab-Archives -
otherwise use 7zip?
In any case, you should end up with an unpacked Folder, named:
..\Microsoft.WebView2.FixedVersionRuntime.107.0.1418.62.x86
somewhere on your local harddisk.
Now move that whole Folder to a place you prefer in your filesystem -
and then point the 3rd Param of the BindTo-method to that Directory-Path-(String).
Olaf
Last edited by Schmidt; Dec 24th, 2022 at 03:54 AM.
Is there a project / template for this so that the WebView2 can also be used as an HTML editor?
Sure ... did you ever try-out:
WV.OpenDevToolsWindow
... after a successful WV.BindTo(...) call?
It's (in the meantime) a full-blown IDE-environment with live-changes in the "View",
as soon as you edit and save *.html and *.css files
(also including support for *.js-Debugging of course).
The DevTools-Window is highly configurable (just play around with it for a day or two) -
and it allows write-interaction with the local FileSystem, once you specify a "trusted root-folder"
(which is usually the root-folder of your "localhost" Webserver-instance - be that NodeJs or IIS or Nginx).
Hello
I tested the demo under w7 but I'm getting this error
The reason for this was mentioned a few times already in this Codebank-Thread.
(the Event-interface was changed slightly in newer RC6-versions).
Just comment out the Event-Handler you're having problems with completely -
and then "re-select" the EventHandler from the DropDown-ComboBox at the TopRight of the IDEs CodeEditor
(in case you need this specific Event at all)...
I've not yet uploaded a new Demo-Zip, because the cWebView2.cls is still getting enhancements -
and is not yet "entirely finalized" (COM-interface-wise)...
I'll always try my best though, to not break the stuff which is currently "in use and established"...
@paliadoyo, Bob17, Resurrected
...or anybody else who previously had problems with loading WebView2 in "other Host-Processes" like:
Excel(32Bit), .NET(32Bit), Powerbuilder(32Bit)
I think I've found (and fixed) something over the Holidays regarding "more robust BindTo/Loading" ...
Please download RC6 version 6.0.12 from the usual place and check with that (after re-registering).
Hi again,
I tested several solutions under Windows 7 but without success.
I confirm that I have no problem under Windows 10.
On the other hand, the source code of Wolf (http://www.ww-a.de/download/WebView2-Demo.zip) works perfectly on Windows 7. However, I could not reproduce the 'BinTo' method of Wolf.
I am disappointed.
If Wolfgangs code is working (in your VB6-IDE on Win7) -
then you're doing something wrong in your "init-sequence"...
Here's a minimal Demo-Code for an empty Project with a Form1 (and a reference to RC6)
Code:
Option Explicit
Private WithEvents WV As cWebView2
Private Sub Form_Load()
Me.Caption = New_c.Version 'just to check, which RC6-Version is in use...
Me.Visible = True 'the FormOrPicBox.hWnd needs to be Visible, before the BindTo-call
Set WV = New_c.WebView2
If WV.BindTo(Me.hWnd) Then
WV.Navigate "https://google.com"
Else
MsgBox "Couldn't bind the WebView to the Form.hWnd"
End If
End Sub
Private Sub Form_Resize() 'ensure full coverage of the Containers ClientArea with the WebView
If Not WV Is Nothing Then WV.SyncSizeToHostWindow
End Sub
Olaf thank you very much for trying to help me but it still doesn't work.
I have checked the registry keys (HKLM and HKCU) concerning the runtime and tried different versions of this runtime but nothing changes.
I will resolve to use it under Windows 10 even if I hate Windows 10....
Hi Olaf,
Good news !
Now it works fine on Windows 7.
Code:
Option Explicit
Private Cairo As cCairo
Private WithEvents WV As cWebView2
Private Sub Form_Load()
Me.Visible = True
Set Cairo = New_c.Cairo
Set WV = New_c.WebView2
Cairo.SetDPIAwareness
If WV.BindTo(Me.hWnd) = 1 Then
Me.Caption = "INIT OK"
WV.Navigate "https://google.com"
Else
MsgBox "Couldn't bind the WebView to the Form.hWnd"
End If
End Sub
Private Sub Form_Resize() 'ensure full coverage of the Containers ClientArea with the WebView
If Not WV Is Nothing Then WV.SyncSizeToHostWindow
End Sub
Last edited by darjeeling; Jan 7th, 2023 at 07:16 AM.
Hi Olaf,
I wanted to test your BindTo improvements but the vbrichclient.com is having some error 500 problems.
Microsoft seems to be forcing everything related to IE to be removed from the browser, and I don't know if the recent frequent failures (inability to download files) of vbrichclient.com are related to Olaf's use of IIS.
Microsoft seems to be forcing everything related to IE to be removed from the browser, and I don't know if the recent frequent failures (inability to download files) of vbrichclient.com are related to Olaf's use of IIS.
Site was just down due to mystery server reasons....it looks like it's back up now. Maybe Olaf should have used Nginx :P
hello Olaf
with currently available versions 108... and 109... of Microsoft.WebView2.FixedVersionRuntime, I have a crash that takes me out of the IDE when calling the BindTo function (WV.BindTo(picWV.hWnd, 8, EdgePath, DataEdgePath, TmpLang) ). I have the same problem when compiling the project
I have no problem with version 103 and I have no problem with the Evergreen version either.
Have you experienced this?
Thank you in advance for your answer
François