InvalidOperationException: Unable to resolve service for type 'System.IFormatProvider' while attempting to activate 'RepositoryService'.

Question: How do you solve Asp.Net 5 Error: "InvalidOperationException: Unable to resolve service for type 'System.IFormatProvider' while attempting to activate 'RepositoryService'."

Answer: If you want to resolve this issue do not try to inject IFormatProvider through the Constructor as this Interface comes with Asp.Net 5 Implementation. There is no need to request the IFormatProvider from the Dependency Container. However, just define the property as below:

private IFormatProvider _provider;

function myFunc(){
int myInt = Convert.ToInt32(YouString,_provider);
}

As a rule of thumb, always test your code before you deploy to production, understand how you would test different scenerial regarding Globalization and Localization.

See Related Article here.


Edit this Article
IFormatProvider Error C-Sharp .NET 5 published
Was this page helpful?
Yes Yes! this solution to the problem was helpful. No No! this solution to the problem was not helpful.. Leave ErnesTech Feedback.Feedback
If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.

Your Session is Ending
Login to Continue

© 2021 - ErnesTech - Privacy