question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple framework target and binding redirect problem

See original GitHub issue

Please let me know if this is not the right place for this type of issue.

Description

  • Multiple-targeted DLL for net472 and netstandard2.0
  • The .NET Framework version of the dll is put in the GAC. It has to be since it is called from code that I injected into other assemblies via the .NET Profiler API.
  • After building (either in VS or msbuild command line), there is a System.Interactive.Async.dll in the binaries directory (e.g., bin\debug\net471). It is the 3.0.3000.0 version.
  • I then go through my automated steps to install my assemblies into a folder from which I add all of them to the GAC (this is just for the net471 , not the netcore2.1, target).
  • I reset IIS, then run a .NET Framework-based web application (it was built against .NET Framework 4.6.1)
  • My profiler instruments the app, and when there is a call to my assembly, an exception occurs:
Exception Could not load file or assembly 'System.Interactive.Async, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263' or one of its dependencies. The system cannot find the file specified.
  • Notice that it is not the same version as the one that was in my net471 binaries folder.

  • I discovered that Grpc.Core, one of my dependent assemblies, relies on version 3.0.1000.0 of System.Interactive.Async.

  • I’ve tried adding a binding redirect both from 3.0.1000.0 to 3.0.3000.0 (and the other way, from 3.0.3000.0 to 3.0.1000.0) in my assembly’s app.config. But it doesn’t seem to work.

  • I even tried putting the binding redirect in a file named Grpc.Core.dll.config in the same directory as the dlls (not in the GAC though), but that didn’t help.

  • Finally, I have no idea why the newer version of System.Interactive.Async.dll is even being put in my net471 binaries folder. I walked through all of the assemblies I include in ILSpy and none of them pull that in.

Any help deciphering what is going on would be fantastic. Thanks in advance!

Bob

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Green7commented, Aug 6, 2018

I have this same problem. AssemblyResolve works:

    AppDomain.CurrentDomain.AssemblyResolve += EmbeddedAssemblyResolver;

    private static Assembly EmbeddedAssemblyResolver(object sender, ResolveEventArgs args)
    {
      if (args.Name.StartsWith("System.Interactive.Async"))
      {
        return Assembly.LoadFile(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "System.Interactive.Async.dll");
      }
      return null;
    }
1reaction
bobuvacommented, Aug 4, 2018

Ok, thanks. I may look into the AssemblyResolve option you mentioned but I know that’s a bear. Well, thanks for thinking about this. If I come up with something I’ll post it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Binding Redirects
The fix if you're using .NET Framework · Enable <AutoGenerateBindingRedirects> (this doesn't work for web projects - it doesn't handle web.config ).
Read more >
Redirecting Assembly Versions - .NET Framework
Redirect compile-time binding references to different versions of .NET assemblies, third-party assemblies, or your own app's assemblies.
Read more >
Assembly binding redirect does not work
My problem was solved when I moved binding redirection configuration to machine.config file. Share.
Read more >
System.Runtime 4.1.2 assembly binding redirects
I have projects targeting .Net Framework 4.7.2, some class libraries, some Azure cloud service worker/web roles, some console apps.
Read more >
How to fix the assembly binding redirect problem in Azure ...
If the assembly is in our binding redirect list, then we load the version specified in the settings, otherwise we do nothing. We...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found