Hi guys,
I'm trying to integrate Dynamics NAV with a .net API from Klarna Services. (
http://integration.klarna.com).
The assembly has a many overloaded methods and I'm getting a lot of "Ambiguous function call, no matching method found" when working with it.
I'm wondering how NAV evaluates and maps to the different overloads based on the C/AL I write, because I can't figure out exactly what this message means.
One example:
A method, reserveAmount, has the following parameters when viewed in Visual Studio Object Browser:
public string[] ReserveAmount(string pno, Klarna.Core.API.Gender? gender, Klarna.Core.API.Flag flags, int pclass)
This shows up in C/AL as:
[string[] ReserveAmount :=] ReserveAmount(string pno, System.Nullable´1 gender, Flag flags, int pclass)
The other overloads have:
public string[] ReserveAmount(string pno, Klarna.Core.API.Gender? gender, Klarna.Core.API.Flag flags, int pclass, Klarna.Core.API.Encoding enc)
public string[] ReserveAmount(string pno, Klarna.Core.API.Gender? gender, double amount, Klarna.Core.API.Flag flags, int pclass)
public string[] ReserveAmount(string pno, Klarna.Core.API.Gender? gender, double amount, Klarna.Core.API.Flag flags, int pclass, Klarna.Core.API.Encoding enc)
No matter what I specify as parameters in C/AL, I get the same error message.
What am I missing here? Can it be something wrong with the Gender parameter, as it converts to System.Nullable´1 or does it have to do with how NAV searches for the right overload to use?
Regards,
Eivind Giske
Comments
The problem is that NAV does not support nullable parameters in .net interop. The parameter "Gender?" is the problem, and it prevents NAV from evaluating which overload to use, hence the message.
When a parameter is nullable, it cannot be used, not with NULL nor with any other value.
The solution in my case was to create a wrapper class in Visual Studio to handle the nullable parameter, in my case by just passing NULL to it. Then use the wrapper in NAV.
Microsoft really needs to address this in future releases, as A LOT of custom assemblies and third party APIs do use nullable parameters.
If anyone has similar issues, don't hesitate to contact me.
Regards,
Eivind Giske
Got that error one time, but it was my own code so I could just create a overloaded function that matched what I needed in NAV.
You should seriously log this in MS Connect or open a support case if you have access to that.
When it gets solved you can ditch your wrapper.
Johannes Sebastian
MB7-840,MB7-841