Find unused / unnecessary assemblyBinding redirects
The solution to this is actually quite simple and elegant.
- Remove all your binding redirects in Web.config / app.config;
- Go to Package Manager Console;
- Enter the command
Add-BindingRedirect
(you can also specify a target project using-ProjectName "SpecificProject"
); - All necessary binding redirects are generated;
- Run your application and see if it works properly. If not, add any missing binding redirects that the command missed.
Most of them are added as part of default template. You can safely remove many of them based on yr need in the application, from binding as well as project reference. This way, if accidentally they are being used as dependency somewhere, you will get to know instantly. For example: -
- "Microsoft.ApplicationInsights": Auditing application
- System.Web.Helpers: Html helpers for MVC
- System.ValueTuple: Tuple as a data structure where you can access each property by name
- System.Threading.Tasks.Extensions: TPL extension methods
- Microsoft.SqlServer.Types: Datatypes registered within SQL server being consumed in app code directly
- Microsoft.Owin.Security: Owin as identity management
- Microsoft.Data.Edm: Entity framework data modelling
- Microsoft.Data.OData: Open Data services
Note that binding redirect is specifically used when your code originally referred/requested an older version and you are providing a newer version. If the version being used is actually the same as the one being provided (primarily for main framework components (rather than updates delivered by NuGet), you can remove bindingRedirect section altogether..
For safety purpose, comment out each section and then run application, if things don't work, you can uncomment the section.