Including the namespace

Each eConnect assembly defines a namespace for the classes that it contains. A .NET namespace is a second organizational method that groups type names in a effort to reduce the chance of a name collision. The eConnect namespaces are as follows:

  • Microsoft.Dynamics.GP.eConnect
  • Microsoft.Dynamics.GP.eConnect.Serialization

You typically includes the namespace when you specify the type of an eConnect object. To demonstrate the use of a namespace, the following Visual Basic example instantiates a GetSopNumber object. Notice how the namespace and class name are used to specify the object type:

'Use GetSopNumber from the Microsoft.Dynamics.GP.eConnect
'namespace
Dim SopNumber As New Microsoft.Dynamics.GP.eConnect.GetSopNumber

To simplify your code, use the Visual Basic Imports statement or C# using statement to specify the namespace from a referenced assembly. These statements eliminate the need to include the namespace when you specify an object type.

The following Visual Basic example uses the Imports statement to add the Microsoft.Dynamics.GP.eConnect namespace to the .vb file of a project. You typically add the Imports statement to the top of the file where you are using the members of that namespace:

Imports Microsoft.Dynamics.GP.eConnect

The following C# example shows how to add a using statement to include namespace information in the .cs file of a project. You typically add the using statement to the top of the file:

using Microsoft.Dynamics.GP.eConnect;

After you use the Imports or using statements to include a namespace, you can use the eConnect class name to specify the type of an object. The following Visual Basic example shows how to import the Microsoft.Dynamics.GP.eConnect namespace and then instantiate a GetSopNumber object.

Imports Microsoft.Dynamics.GP.eConnect
'Use GetSopNumber from the Microsoft.Dynamics.GP.eConnect namespace
Dim SopNumber As New GetSopNumber

If you are using the eConnect Integration Service you can use Imports or using statements for the service reference. The following Visual Basic example shows how to import the service reference for an application named VbTestApp.

Imports vbServiceTestApp.eConnectIntegrationService

The following C# code example shows how to add a using statement for a service reference to an application named ServiceTestApp.

using ServiceTestApp.eConnectIntegrationService;