Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueTuple 4.0.2 dependency in System.Reactive #823

Closed
thomas-berg opened this issue Oct 4, 2018 · 16 comments
Closed

ValueTuple 4.0.2 dependency in System.Reactive #823

thomas-berg opened this issue Oct 4, 2018 · 16 comments

Comments

@thomas-berg
Copy link

.NET Framework 4.7.1
System.Reactive 4.1.1 from nuget installs dependency package ValueTuple 4.4.0 (v4.0.2), all good.

Updating ValueTuple package to 4.5.0 (v4.0.3) causes this runtime exception in System.Reactive:

Could not load file or assembly 'System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at System.Reactive.Producer2.SubscribeRaw(IObserver1 observer, Boolean enableSafeguard)
at System.Reactive.Producer2.Subscribe(IObserver1 observer)
at System.ObservableExtensions.Subscribe[T](IObservable1 source, Action1 onNext)

@clairernovotny
Copy link
Member

What kind of project is it? The project file should have AutoGenerateBindingRedirects set to true, which should add the necessary binding redirect entries:
https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/how-to-enable-and-disable-automatic-binding-redirection

@thomas-berg
Copy link
Author

It is a desktop application. AutoGenerateBindingRedirects is true both in the Visual Studio interface and the .csproj file. The app.config dependentAssembly entry is:

<dependentAssembly> <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /> </dependentAssembly>

I can reproduce it by upgrading ValueTupe package to 4.5, build release configuration & deploy to production and reverting to working setup by uninstalling System.Reactive 4.1.1 & ValueTupe 4.5 packages & reinstalling System.Reactive 4.1.1.

@joperezr
Copy link
Member

joperezr commented Oct 8, 2018

@thomas-berg do you mind sharing a binlog for us to investigate the issue? To produce one, simply run msbuild yourProject.csproj /t:rebuild /bl from a developer command prompt. Do not use the latest version of the package to workaround the issue when you generate the binlog, since we are interested in the case that seems to be broken.

@thomas-berg
Copy link
Author

Binlog attached of the version that throws in production environment (nuget System.Reactive 4.1.1 followed by updating ValueTuple package to 4.5.0)

msbuild.zip

@joperezr
Copy link
Member

joperezr commented Oct 9, 2018

Thanks, I'm taking a look now. Did the Value tuple redirect got added automatically? or did you add it manually?

@joperezr
Copy link
Member

joperezr commented Oct 9, 2018

Also, in case you added it manually, which by looking at the log that seems to be the case, does your app run fine after adding it? What happens if you remove the redirect?

@joperezr
Copy link
Member

joperezr commented Oct 9, 2018

I see, I guess you didn't actually added the redirect manually, but you are still using packages.config so the NuGet updater in VS added the redirect for you. I tried a simple repro locally but switched to use PackageReference instead of packages.config, and the right redirect was added to my config file and I don't see an error at runtime. If you could provide a simple repro project, I could try migrating it to PackageReference to see if that would fix the issue.

@rstroilov
Copy link

rstroilov commented Oct 10, 2018

We also have faced this issue, spent some time yesterday to investigate and fix.

  1. We didn't have Binding redirect added automatically;
  2. If remove it (and clean packages cache), then app fails on startup;
  3. With redirect app runs fine.

@thomas-berg
Copy link
Author

This was a Framework version mismatch on our deployment machine. The application was built targeting v. 4.7.1 but the deployment machine was on v.4.6.1. Since the AppName.exe.config file was not deployed the application started just fine.

Upgrading to .NET Framework 4.7.2 on the deployment machine fixed this issue.

Sorry about the false alarm, for my part this issue can be closed.

@IGx89
Copy link

IGx89 commented Jan 7, 2019

Just ran into this too on a WPF net471 application using package.config. System.Reactive shouldn't even have a dependency on System.ValueTuple on net47 and newer since it's built into the framework -- see #840

@clairernovotny
Copy link
Member

@IGx89 What if you try @joperezr's suggestion of using PackageReference? You can right-click packages.config and select migrate.

Rx does not currently target 4.7 specifically; it targets 4.6.x and up.

@IGx89
Copy link

IGx89 commented Jan 7, 2019

My solution has 20 projects and uses ClickOnce which has known issues using PackageReference under net471 (supposedly net472 is better, but we can't switch to that yet), so switching over is too big and problematic of a task still.

Correct. Proper solution would be to add another target for 4.7 that doesn't have the ValueTuple dependency.

@IGx89
Copy link

IGx89 commented Jan 7, 2019

Here are a couple examples of NuGet package that do that:

https://www.nuget.org/packages/FluentAssertions/
https://www.nuget.org/packages/Microsoft.FSharpLu.Json/

@glennawatson
Copy link

@IGx89 In VS 2017 15.8.5 and beyond series fixed problems with ClickOnce and PackageReference.

@michaelkhalsa
Copy link

michaelkhalsa commented Jun 1, 2019

Have problems with this as well on a build targeting 4.7.2 (with several dozen projects)
It use to target 4.6.1, and worked fine.
Using Package Reference with Auto Enable Binding Redirects turned on.
It builds locally Control-F5 fine and runs. The problem is when packaging it up using Microsoft Project Installer (version .93-latest) for a winforms desktop app, it does not appear to honor the redirects (also applied redirects manually, no difference). It installs fine using msi file, but gets a runtime error on first instance of my code using the .net framework 4.7.2 ValueTuples because of the duplicate namespaces from System.ValueTuple assembly. I tried cutting the System.Value.Tuple assembly from installer, however that just gives a missing assembly error.

It does include the redirect in the ...exe.config file for the executable in the install directory
--dependentAssembly--
--assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" --
--bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" --
--dependentAssembly-- (replaced xml brackets)

Is there some kind of behind the scenes magic band-aid, or something that is different in a visual studio (non-debug) running of the app, and one installed onto a machine (Windows 10 latest, no registry entries).

Any suggestions?

Thanks

@michaelkhalsa
Copy link

Ok, If i go into the config file for the app as installed in c:/Program Files
and remove the binding redirect for System.ValueTuple now it works.
Removing this

--dependentAssembly--
--assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" --
--bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" --
--dependentAssembly-- (replaced xml brackets)

Of course, will have to figure out how to tell Microsoft Project Installer not to add this in, however this is a separate issue. It is not in the app.config files themselves for the project.

If anyone has any idea, appreciate it,

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants