Creating an extension assembly
To create an extension assembly, complete the following steps:
Create a new class library.
In Visual Studio, create a new project that has the type Class Library.
Warning: You must be using Visual Studio 2010 or later, and your project must target the .NET Framework 4.
Add references to Dynamics GP web service assemblies.
Add references to the following assemblies from the main folder for the Dynamics GP web service.
• Microsoft.Dynamics.Common
• Microsoft.Dynamics.Common.Types
• Microsoft.Dynamics.GP.BusinessLogic
These assemblies are typically found in this location:
C:\Program Files\Microsoft Dynamics\GPWebServices
Add namespace references.
Add using (C#) or Imports (Visual Basic) statements to provide convenient access to the classes and methods needed for the extension assembly. Include the following:
• Microsoft.Dynamics.Common
• Microsoft.Dynamics.GP
• System.Data
• System.Data.SqlClient
• System.Xml
Hint: The Data, SqlClient, and Xml namespaces are added to provide access to resources you will need when you write your event handling methods.
Specify the name for the namespace.
In the code for the class library, specify the name for the namespace. Use a name that indicates who created the web service extension or what type of extended data is being made available.
Add a public static class.
This new class in the extension assembly will contain the static methods that respond to Dynamics GP service events. Be sure the class is marked public and static. The following C# code is an example of a public class for an extension assembly:
using System;
using System.Data; using System.Data.SqlClient; using System.Xml; using Microsoft.Dynamics.Common; using Microsoft.Dynamics.GP;
namespace ExtensionExample { public static class ContactHistory { // Event handler methods are added here } }
Add the event handler methods.
These public static method will respond to the events from the Dynamics GP service. For more information about these methods, refer to Event handler methods.
Build and deploy the extension assembly.
Once the extension assembly has been built, copy it to the folder for the Dynamics GP web service installation. Typically this will be in the following location:
C:\Program Files\Microsoft Dynamics\GPWebServices