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'."


Login to See the Rest of the Answer

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.







For peering opportunity Autonomouse System Number: AS401345 Custom Software Development at ErnesTech Email Address[email protected]