waldo’s blog

Microsoft Dynamics NAV

.NET Interop: Issue with return parameter overloading solved

In my previous post, I mentioned a problem with .Net Interop, when you tried to use it with a SQLConnection. In fact, the System.Data hasn’t anything to do with the source of the problem, but it was the namespace where I encountered it a few times, so I’m going to take that example to show you the problem …

… if we use the out-of-the-box R2 build 32012

When you’re using the default build (32012), then you’re in trouble .. or at least .. the chance exists that you’re in trouble. When calling stored procedures, you often provide parameters to your command. Remember from my previous post, a line of code like:

SQLCommand.Parameters.Add(SQLParameter);

This line of code causes a compile error in build 32012:

And the reason for it is that this build of NAV 2009 R2 doesn’t support methods/properties that are overloaded on the return parameters.. . So this is not only a problem for “parameters”, but for any method or property in the .Net framework, where (only) the return parameter was overloaded.

You can notice that when you look at the definition in your symbol menu:

An overloading on “Parameters”, and the return value is different (but not that different though..at least in this case).

Bottom line: technically, there is no way for you to add parameters to your command .. so using parameters this way in this build is a no-go .. . Now, for this particular case (using parameters on a SQLCommand), there are a few workarounds though. You can find one in Rashed’s post and one in David’s post.
Bottom line

There are no (known) issues in the latest build .. So be sure to use it (or at least, use a build higher than 32198)! And if you don’t know where to find it .. I tend to keep track of Platform Updates. Just use the tag cloud and click “Platform Updates” and take the most recent one:

http://dynamicsuser.net/blogs/waldo/archive/tags/Platform+Updates/default.aspx

July 25th, 2011 Posted by waldo | Dynamics NAV | no comments