Dynamics GP Developer Insights: .NET Interop
Hello, my name is Alice Newsam and I am software engineer on the Dynamics GP team focusing on Dexterity and I have a question for you:
Have you ever thought to yourself while working in Dexterity “I know there’s a .NET class that does this. It would be handy to access that right about now.” or “If only I could increase the string size to hold that data.”?
Well read on because you’ll be excited to learn about a feature that the GP Development team is currently working on for the GP 2015 release: .NET Interop.
This feature will bring the power of the .NET Framework into sanScript. Using .NET Interop, you’ll be able to reference .NET assemblies in your Dexterity dictionaries and your sanScript code will be able to create .NET objects and access fields, properties, methods, and events on those objects. Using .NET objects from sanScript can afford you greater flexibility to overcome things like sanScript’s limited string size, allow you to use dynamically sized collections, and give you direct access to alternate data sources like ADO.net.
How about a simple example to demonstrate:
Here you can see that the syntax is very similar to C#. We start off with a using directive which will allow us to use types from a namespace in a .NET library that we are referencing from our dictionary. That library contains a class for the Customer object which we are creating with the ‘new’ statement and will be returned to the caller of this procedure. Next you can see where we are interacting with the object by setting properties and calling methods. This is just a simple example of what can be done with .NET Interop, but you can imagine many more scenarios using existing .NET libraries and objects to help provide solutions for business scenarios.
Another benefit of the .NET Interop feature is that it expands on the capability to consume web services from within sanScript. The .NET Framework provides several classes that can be used to make web service calls and interpret the data used in the call. Along with helping to consume web services the .NET Interop feature also supports the effort to expose web services from Dynamics GP by providing a convenient mechanism for sending data in and out of a service procedure. This opens the possibilities up for a tremendous number of scenarios to extend and enhance the current product.
Additionally, along with unleashing the power of the .NET Framework via sanScript, the .NET Interop feature is also a foundational step to executing on the vision of Dynamics GP moving more fully towards a service based architecture. Since you can now reference and interact with a .NET object in Dexterity you can also use them as parameters for a service call. By reimagining the abilities of the toolset in this manner, the logic can be fully leveraged by Dynamics GP as well as contain additional logic for things like companion and integrating applications.
The realization of features such as .NET Interop and others facilitating the new Service Based Architecture will provide an opportunity for the Dynamics GP application to significantly enhance reach and capability. It not only will be able to more easily connect to other systems and services but also provide all of its capability for others to consume. This will make for some exciting times ahead.
Stay tuned!
Alice
Comments
Anonymous
July 08, 2014
Wow Interop has only been around 13+ years and you just now got sanScript to work. You will bury yourselves with your ancient tools.Anonymous
July 08, 2014
Hi B Our ancient tools, namely Dexterity and its scripting language sanScript has served us very well over the years and continues to serve us. Dexterity forms an abstraction layer from the operating system and the database platform and has allowed code written 20 years ago to still run today, even in a web client. When Dexterity gained new functionality, all developers received that functionality with little or no effort on their behalf: For example: SQL Support, VBA Support, UI Improvements, Web Client. These latest enhancements will just add to the arsenal of tools we have with Dexterity, VBA, Visual Studio, etc. DavidAnonymous
July 10, 2014
Great news! No more proxy DLL for web services consumption!Anonymous
July 10, 2014
Hi Marcos Great times are ahead. DavidAnonymous
August 12, 2014
So, are you expanding the sanScript language to include the foreach..in construct and other important constructs to address one of .NET's biggest foundations which is collections? Is it possible to get a preview document of the sanScript reference? I know a lot of this stuff is not set in stone, but it would help Dex developers all over to transition a lot easier to developing with these new constructs. Keep in mind that not all Dex developers are .NET developers and things like web services and even collections are still foreign concepts to most. Better yet, why not have a Weekly Dynamics GP Developer Insight showing practical examples on how this stuff will work. Also, why not deal with the inherent deficiencies in sanScript while you are at it? Why not expand the string datatype to a larger size? Or the integer datatype to match at least those in .NET? I still cannot understand these self-imposed restrictions. Unrelated (not!), but when is Dexterity going to introduce support for SQL Server VARCHAR and NVARCHAR data types? CHAR is outdated and consumes tons of database space with a whole bunch of empty strings. When will we see support for Unicode? When will we see support for other database code pages? Please don't misinterpret my questions as attacks. I am truly excited about the new functionality, but like everyone else, I'm always left wanting more. MG.- Mariano Gomez Microsoft Dynamics GP MVP Intelligent Partnerships, LLC www.intelligentpartnerships.comAnonymous
August 12, 2014
The comment has been removedAnonymous
August 26, 2014
Hi Mariano I got the response back from the development team: "We thank Mr. Gomez for his commentary regarding the Dexterity IDE and understand that advocates like himself will always desire additional capability in order to deliver increased value to our mutual customer base. We plan to continue our investment in the tools and technologies to enable features that best serve the needs of that base. The last several releases have demonstrated that continued investment through the delivery of technologies like Web Client, Workflow and Doc Attach, which at their core utilize the Dexterity runtime and IDE as an evolving platform able to support the current and future needs of our partners and customers." DavidAnonymous
May 14, 2019
Can you tell me if .NET Interop for Dexterity supports Nullable types? I've got a library with a property of type decimal? which I am trying to use in Dexterity. I cannot set a local vcurrency variable to equal this property and I've tried a few ways of casting it. I continue receiving the error "object does not match target type".- Anonymous
May 14, 2019
Okay, after several attempts I finally realized I can simply add "using System;" to my script and use Convert.ToDecimal() on the nullable property.
- Anonymous