So we have a rates calculator class in our ASP.NET4 web app that uses the Microsoft.VisualBasic.Financial.Rate to calculate a nominal rate (based on input parameters).
We noticed that for high values of NPer (total number of payment periods, e.g. 50 years x monthly payments = 600) the function would throw an exception: Cannot calculate rate using the arguments provided.
Searching around we did not find any solutions to this, so I am posting the solution here. A requirement for us was to maintain a function that as closely as possible implemented the same algorithm as the above, as we needed to produce exactly the same outputs.
Answering my own question, for any future coders who run into this problem – we used dotPeek to decompile the module, which produced the following:
We can see the error is thrown if num3 is exceeded, as it has a hard limit at 39. We tidied up the code a little, and increased the limit to 100: