Method not found: 'System.String System.String.Format(System.IFormatProvider, System.String, System.Object)

Dale Alleshouse picture Dale Alleshouse · May 31, 2015 · Viewed 29.6k times · Source

I have a Web API 2 project with help pages that runs fine locally but throws this error when I push it to Azure:

Method not found: 'System.String System.String.Format (System.IFormatProvider, System.String, System.Object)

I temporarily turned custom errors off so full stack trace can be seen here

The error is originating from this line of code:

string selectExpression = String.Format(CultureInfo.InvariantCulture, MethodExpression, GetMemberName(reflectedActionDescriptor.MethodInfo));

See Line 96 here

The full source code is available on GitHub

I'm not even sure where to go with this one.

Answer

CodeCaster picture CodeCaster · May 31, 2015

According to its MSDN page, the overload you're using is only supported on .NET 4.6.

Either configure the host to run .NET 4.6 or change the target framework of the project to 4.5 and recompile.

In 4.5 there's a params object[] overload which will then be chosen, without having to alter your code.