question

KedarBhapkar-5697 avatar image
0 Votes"
KedarBhapkar-5697 asked LanHuang-MSFT answered

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

i'm getting below Error while loading Report

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

262979-error.png


dotnet-aspnet-webforms
error.png (120.5 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

LanHuang-MSFT avatar image
0 Votes"
LanHuang-MSFT answered

Hi @KedarBhapkar-5697,
According to its MSDN page,
https://learn.microsoft.com/en-us/dotnet/api/system.string.format?redirectedfrom=MSDN&view=net-7.0#System_String_Format_System_IFormatProvider_System_String_System_Object_
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.
https://learn.microsoft.com/en-us/dotnet/api/system.string.format?redirectedfrom=MSDN&view=netframework-4.5#System_String_Format_System_IFormatProvider_System_String_System_Object_
If you can neither upgrade host to 4.6 nor downgrade project to 4.5 there is a workaround : pass an "object[]" as args instead of an "object".
So you will force usage of the "params object[]" overload. Example :
return string.Format(formatProvider, "{0:" + format + "}", new object[] { value });
Best regards,
Lan Huang


If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.