1.7.4 crashes because of webview2 version mismatch
I updated to from 1.7.3 to 1.7.4 and it now crashes when an update is found.
It gives the following error :
Could not load file or assembly 'Microsoft.Web.WebView2.WinForms, Version=1.0.1264.42, Culture=neutral, PublicKeyToken=2a8ab48044d2601e'.
Seems like in f6797c4, the version reference to WebView2 was changed as follows.
- <PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1210.39" />
+ <PackageReference Include="Microsoft.Web.WebView2" Version="1.*" />
As a result of this, the latest version is included in the project, 1.0.1264.42 at the time of writing.
But the required dependency is still 1.0.1210.39 so it doesn't update to 1.0.1264.42 automatically, causing the missing file.
<dependency id="Microsoft.Web.WebView2" version="[1.0.1210.39,2)" exclude="Build,Analyzers" />
"[1.0.1210.39,2)" means that the minimum required dependency is 1.0.1210.39, but it should work with a version below 2.x. It may be happening due to binding redirects in App.config. Can you try updating your WebView2 NuGet package and removing any binding redirects related to WebView2 if it doesn't work?
I installed the latest version of the WebView2 NuGet package, 1.0.1210.42 and that fixes it because the crash was due to it not finding the .42 assembly. I shouldn't have to do this however, the package should install the right versions of its dependencies on its own. The line <dependency id="Microsoft.Web.WebView2" version="[1.0.1210.39,2)" exclude="Build,Analyzers" />
just makes sure the package WebView2 of a version between 1.0.1210.39 and 2.x is installed, and if it doesn't find a matching version, it installs an appropriate version for you. I had version 1.0.1210.39 installed so all was fine for this line of code. However it then crashed stating it couldn't find version 1.0.1210.42 so either this requirement should be updated to require at least version .42 so it downloads that version on its own or it should work with version 1.0.1210.39 again and I think it stopped working with 1.0.1210.39 because of the package reference changing here which is where you define what packaged the app uses, not what should be installed like we did with the <dependency/> tag:
- <PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1210.39" />
+ <PackageReference Include="Microsoft.Web.WebView2" Version="1.*" />
Here 1.* is referenced which defaults to the latest version and that version only, 1.0.1210.42 so that is why it complained that it can't find that version. Here you should also specify a version range, just like it is done in the <depencency/> tag, like is demonstrated here: https://docs.microsoft.com/en-us/nuget/concepts/package-versioning#references-in-project-files-packagereference. I could be misunderstanding this but that is my theory about why this stopped working all of a sudden.
Edits: formatting
1.* means that it should accept any 1.x version, so it should work with all 1.x versions. I don't think changing that will change this behavior. I don't know why it crashed, it may be not copying the all the DLLs to output directory with previous versions and updating it may fix it, but setting that to specific version causes problems when new version of WebView2 is released. I changed it to accept all 1.x cause issue #547.
well idk either then, I'm on vacation now but when I'm back next week I'll see if I can find a way to reliably reproduce the crash so you can debug it further and find out what went wrong
So what happens now to all the users that got the update? I have to manually update the app to their computers or there is another solution?
I reverted to the fixed version in v1.7.5 so, it should fix this, but this means issue #547 can resurface in the future when new WebView2 update releases.
@achilleaskar If users got the version where there is exception while updating, then they have to manually update to fixed version.