I had a problem with a custom created COM dll in the NAV 2009 R2 RTC:
I made my own COM visible dll in .NET to use in NAV by means of automation.
In the Classic Client, everything worked fine. When running the same code in RTC I got the error:
"The server ... is either unavailable or your connection has been lost. Do you want to attempt to reconnect?"
The event log contained the error message:
"Must specify binding flags describing the invoke operation required"
The dll was installed on the client and the service tier. The automation objects where set to be created on the clients. I changed this so that they be created on the service (which is better whatsoever because then all the clients don't need to have the dll installed). The RTC error message stayed the same. The event view error message changed to AmbiguousMatchException.
Then it occurred to me that the method being called on the automation variable was an overloaded method. In other words, there were two methods with the same name (but different parameters) in the dll class. Apperently the Classic client has no problems with that, but the RTC obviously doesn't know which of the two methods to take hence causing an AmbiguousMatchException. So I adjusted the dll removing the second method with the same name and that solved the problem.
It took quite some time to figure all this out, so I thought I'd share this
.
Comments
This only works if you are using the RTC or Web Service Tier and it is not supported in the classic client.
See: http://msdn.microsoft.com/en-us/library/gg502499.aspx
Epimatic Corp.
http://www.epimatic.com
Are you sure? COM doesn't support overloading. When overloading it creates new methods with an end-prefix if I remember correctly (like method_2).
An example:
void SetBackColor(int red, int green, int blue, [DefaultParameterValueAttribute(-1)]int alpha);
This gives the optional argument, they must be placed after normal arguments.
(RTC doesn't support this, so all existing arguments must be used.)
Yes it does create the extra methods with the suffixes like you say.
But they only work in the classic client, not in RTC.
It compiles correctly, but when running the code in RTC (first method or second method) I get the same error.
When you look at the stack trace in the event viewer, it is clear that generated .NET code of the RTC calles the methods in the dll by reflexion and based only on the method name, it doesn't know which of the two methods to take, so an error is thrown.
After removing the overloaded method, everything worked fine.