This document is archived and information here might be outdated.  Recommended version.

INAContextEdit.Bind Method (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > ArcObjects namespaces > NetworkAnalyst > ESRI.ArcGIS.NetworkAnalyst > Interfaces > IN > INAContextEdit Interface > INAContextEdit.Bind Method
ArcGIS Developer Help

INAContextEdit.Bind Method

Prepare the context for analysis based upon the current network dataset schema.

[Visual Basic .NET]
Public Sub Bind ( _
    ByVal pNetworkDataset As INetworkDataset, _
    ByVal pGPMessages As IGPMessages _
public void Bind (
    INetworkDataset pNetworkDataset,
    IGPMessages pGPMessages
  INetworkDataset* pNetworkDataset,
  IGPMessages* pGPMessages
pNetworkDataset [in]

pNetworkDataset is a parameter of type INetworkDataset* pGPMessages [in]
pGPMessages is a parameter of type IGPMessages*

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server. Requires Network Analyst Extension.


Bind attaches the NAContext to the input NetworkDataset.  This ensures the NAContext is properly initialized based on the network dataset specified.

You must call Bind after calling CreateContext on NASolver.


This illustrates how you can create a new NAContext and bind the NetworkDataset to it.

public INAContext CreateContextAndBindToNetworkDataset(INetworkDataset networkDataset)
  INASolver naSolver = new NARouteSolver() as INASolver;
  IDENetworkDataset deNetworkDataset = ((IDatasetComponent)networkDataset).DataElement as IDENetworkDataset;
  INAContext context = naSolver.CreateContext(deNetworkDataset, naSolver.DisplayName) as INAContext;
  INAContextEdit contextEdit = (INAContextEdit)context;
  contextEdit.Bind(networkDataset,  new GPMessagesClass());

  return context;


S_FALSE will be returned if bind was successful but something was changed in the context during bind.  S_OK will be returned if nothing was modified.  Any other condition will cause it not to bind and an error HRESULT will be returned.

See Also

INAContextEdit Interface

.NET Samples

Closest facility solver Location-allocation solver Origin-destination cost matrix solver Service area solver Vehicle routing problem solver