Custom Tool Error: after switching project from .net 4.5 to .Net 4.6.1


I have upgraded my project from .Net 4.5 to .Net 4.6.1 and am now getting the following errors when trying to compile:

The "GenerateBindingRedirects" task failed unexpectedly. System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Build.Tasks.GenerateBindingRedirects.UpdateExistingBindingRedirects(XElement runtimeNode, IDictionary`2 redirects) at Microsoft.Build.Tasks.GenerateBindingRedirects.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()

Custom tool error: Failed to generate file: An error occurred creating the configuration section handler for system.serviceModel/bindings: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG)) (C:\ALM[BranchName]\Common[ProjectName]\app.config line 48) Portal.Interface C:\ALM[BranchName]\Common[ProjectName]\Service References[ServiceName]\Reference.svcmap

Based on other searches, I've tried: Removing the ServiceModel section in app config and updating service references. This doesn't work though, because I do not have access to the services from my machine.

I've also confirmed that the service references are configured with "Reuse types in referenced assemblies" is unchecked.

One search led me to removing one of the entries in Reference.svcmap, but was non-specific on what entry should be removed.

I'm definitely out of my element with service references so any help would be appreciated.

asked on Stack Overflow May 18, 2016 by DontThinkJustGo • edited May 18, 2016 by Sinatr

2 Answers


The offending line:

private void UpdateExistingBindingRedirects(XElement runtimeNode, IDictionary<AssemblyName, string> redirects)
    var publicKeyToken = assemblyIdentity.Attribute("publicKeyToken");
    var publicKeyTokenValue = publicKeyToken.Value;

looks like you cannot redirect assemblies that are not strong-named. which means I should just be able to remove the entries. This does make me wonder how this worked before in .Net 4.5

answered on Stack Overflow May 18, 2016 by DontThinkJustGo

Specifying publicKeyToken="null" fixes it for me.

answered on Stack Overflow Mar 6, 2020 by Viacheslav Ivanov

User contributions licensed under CC BY-SA 3.0