18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

.NET APPLICATION PROGRAMMING INTERFACE<br />

End Try<br />

End Sub<br />

[C#]<br />

private void doSomthing_Click(object sender, System.EventArgs e)<br />

{<br />

using (WebObject webobj = new WebObject())<br />

{<br />

ServerConnection serverConn = new ServerConnection("doug",true);<br />

IServerObjectManager som = serverConn.ServerObjectManager;<br />

IServerContext ctx = som.CreateServerContext("Yellowstone","MapServer");<br />

IMapServer mapsrv = ctx.ServerObject as IMapServer;<br />

IMapServerObjects mapo = mapsrv as IMapServerObjects;<br />

IMap map = mapo.get_Map(mapsrv.DefaultMapName);<br />

IFeatureLayer flayer = map.get_Layer(0) as IFeatureLayer;<br />

IFeatureClass fclass = flayer.FeatureClass;<br />

IFeatureCursor fcursor = fclass.Search(null, true);<br />

webobj.ManageLifetime(fcursor);<br />

IFeature f = null;<br />

while ((f = fcursor.NextFeature()) != null)<br />

{<br />

// Do something with the feature.<br />

}<br />

}<br />

}<br />

ctx.ReleaseContext();<br />

The WebMap, WebGeocode, and WebPageLayout objects also have a ManageLifetime<br />

method. If you are using, for example, a WebMap and scope your code in a using<br />

block, you can rely on these objects to explicitly release objects you add with<br />

ManageLifetime at the end of the using block.<br />

Note that .NET Support is a separate option in<br />

the <strong>ArcGIS</strong> installation; this needs to be selected<br />

during installation on both the development and<br />

target machines for .NET customizations to<br />

succeed. If you did not install .NET Support<br />

originally, you can run the installation program<br />

again and choose the Modify option to add<br />

features to your <strong>ArcGIS</strong> installation.<br />

178 • <strong>ArcGIS</strong> <strong>Engine</strong> <strong>Developer</strong> <strong>Guide</strong><br />

Deploying .NET <strong>ArcGIS</strong> customizations<br />

All <strong>ArcGIS</strong> <strong>Engine</strong> and Desktop customizations require an <strong>ArcGIS</strong> installation on<br />

all client machines. The <strong>ArcGIS</strong> installation must include the ESRI primary<br />

interop assemblies, which the setup program installs in the global assembly cache.<br />

For example, deploying a standalone GIS application that only requires an<br />

<strong>ArcGIS</strong> <strong>Engine</strong> license requires an <strong>ArcGIS</strong> <strong>Engine</strong> installation on all target machines.<br />

Standalone applications<br />

Deploying standalone applications to either <strong>ArcGIS</strong> <strong>Engine</strong> or Desktop clients<br />

involves copying over the executable to the client machine. Copying over the<br />

executable can be as simple as using xcopy or more involved such as creating a<br />

custom install or setup program. Note that aside from the <strong>ArcGIS</strong> primary<br />

interop assemblies and the .NET Framework assemblies, all dependencies must<br />

also be packaged and deployed.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!