C
C#17mo ago
Jii

❔ Redirecting assembly versions

Hello everyone, I'm seeking for a guide/help here. Has anyone experience with configure redirecting assembly versions for application with dot NET6 target framework? I'm not familiar, thus can anyone show some sample or URL link that I can refer to.
10 Replies
JakenVeina
JakenVeina17mo ago
assembly redirects are kinda sorta no longer a thing, in .NET 6 since .NET Core they got rid of the system where you configure redirects manually in app.config or web.config instead, the runtime has been made smart enough to do it automatically for all the basic scenarios if you need something more complicated than that, it's essentially not recommended and not supported
JakenVeina
JakenVeina17mo ago
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.
JakenVeina
JakenVeina17mo ago
this article is specified as only applicable to .NET Framework, with a link to another article for .NET Core and onward and that article simply does not discuss version redirecting at all
JakenVeina
JakenVeina17mo ago
Dependency loading - .NET
Overview of managed and unmanaged dependency loading in .NET 5+ and .NET Core
JakenVeina
JakenVeina17mo ago
the practical outcome of this is that it's on you to ensure that there are no incompatible versions of the same assembly, anywhere in your dependency tree the runtime will load the most-recent one it finds (or maybe something even more recent than that, if that's what's in your deployment environment?) so, like if you have dependencies A and B which both reference C if A references C version 1.0.0 and B references C version 1.1.0 the runtime will load 1.1.0 automatically, and everything's good (assuming the publisher of C is correctly implementing semver) however if the two versions are 1.0.0 and 2.0.0 that's potentially bad I think the framework will still load it all, but you run the risk of 2.0.0 having removed an API call that is needed, or having some other breaking change, and your project can then throw exceptions at runtime or worse in this scenario, it would be on you to either upgrade A until it uses a 2.0.0 compatible version of C, or downgrade B until it uses a 1.0.0 compatible version of C anyway, that's my understanding from the last time I had binding issues like this in .NET Core and I've done it a little bit in .NET Framework, but never anything more complex than the 1.0.0/1.1.0 scenario I described what's your actual scenario here?
Jii
JiiOP17mo ago
hey @ReactiveVeina , appreciate for ur long explanation. looks like i'm happy with ur explanation, something that i can digest easily compare to the Microsoft article. yeah, my actual scenario is very similar as per ur example given above. dependencies A and B which both reference C. currently i manually update the lower version to highest version via npm. and, i just looking for an alternative solution that can help me resolve this in code level and will not frequently require modification on csproj file.
JakenVeina
JakenVeina17mo ago
yeah, I don't know of any nice tools that can do that kind of dependency-tree analysis for .NET although, then I think of what those tools look like in JS-land, and shudder
Jii
JiiOP17mo ago
@ReactiveVeina i found something related to this topic in stackoverflow. u can refer my ss here. does this help me to resolve my problem. here is the link btw https://stackoverflow.com/questions/46111749/adding-a-bindingredirect-to-a-net-standard-library/46120907#46120907
Stack Overflow
Adding a bindingRedirect to a .Net Standard library
I have a .Net Standard library, and I'm getting an error when trying to use one of the dependant libraries, which I believe is down to a version conflict. In an old style .Net Class library, I mig...
JakenVeina
JakenVeina17mo ago
does this help me resolve my problem
I mean, no, not really? the point is that you DON'T resolve your problem it's resolved automatically and if it's not, it's because you simply can't do it you can't pull dependencies that have transient dependencies of incompatible versions
Accord
Accord17mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server