7 votos

E_FAIL cuando se llama a ESRI.ArcGIS.Carto.IImageServer.Inicializar()?

Estoy utilizando ArcGIS Engine y el Kit de Desarrollador de 10 en Windows 7. Específicamente, estoy escribiendo una ArcObjects programa de consola de Visual C# 2008 Express.

Estoy intentando conectar a un servidor de imágenes a través de una URL (por ejemplo, http://server/.../ImageServer), pero me da un HRESULT E_FAIL excepción cuando llamo IImageServerLayer.Initialize(). El mensaje completo es "Error HRESULT E_FAIL ha sido devuelto por una llamada a un componente COM." No hay mucha información sobre este error. Algún consejo sobre lo que podría estar equivocado? Aquí está mi código:

using System;
using System.Collections.Generic;
using System.Text;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.DataSourcesRaster;
using ESRI.ArcGIS.GISClient;

namespace EngineConsoleApplication1
{
    class Program
    {
        private static LicenseInitializer m_AOLicenseInitializer = new EngineConsoleApplication1.LicenseInitializer();

        [STAThread()]
        static void Main(string[] args)
        {
            //ESRI License Initializer generated code.
            m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeEngine },
            new esriLicenseExtensionCode[] { esriLicenseExtensionCode.esriLicenseExtensionCode3DAnalyst, esriLicenseExtensionCode.esriLicenseExtensionCodeNetwork, esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst, esriLicenseExtensionCode.esriLicenseExtensionCodeSchematics, esriLicenseExtensionCode.esriLicenseExtensionCodeMLE, esriLicenseExtensionCode.esriLicenseExtensionCodeDataInteroperability, esriLicenseExtensionCode.esriLicenseExtensionCodeTracking });
            //ESRI License Initializer generated code.
            //Do not make any call to ArcObjects after ShutDownApplication()

            //Create an image server layer by passing a URL.
            IImageServerLayer imageserverlayer = new ImageServerLayerClass();
            string URL = "http://vega/ArcGIS/rest/services/grandcanyon/ImageServer";
            imageserverlayer.Initialize(URL); // "Error HRESULT E_FAIL has been returned from a call to a COM component."

            //Get the raster from the image server layer.
            IRaster raster = imageserverlayer.Raster;

            //The raster from an image server is normally large; 
            //define the size of the raster.
            IRasterProps rasterProps = (IRasterProps)raster;
            IEnvelope clipEnvelope = new EnvelopeClass();
            clipEnvelope.PutCoords(779000, 9628000, 786000, 9634000);
            rasterProps.Extent = clipEnvelope;
            rasterProps.Width = 256;
            rasterProps.Height = 256;

            //Save the clipped raster to the file geodatabase.
            ISaveAs saveas = (ISaveAs)raster;
            Type factoryType = Type.GetTypeFromProgID(
                "esriDataSourcesGDB.FileGDBWorkspaceFactory");
            IWorkspaceFactory workspaceFact = (IWorkspaceFactory)Activator.CreateInstance
                (factoryType);
            IWorkspace workspace = workspaceFact.OpenFromFile(@"c:\temp\fgdb.gdb", 0);
            saveas.SaveAs("clipfromimageserverlayer", workspace, "gdb");

            m_AOLicenseInitializer.ShutdownApplication();
        }
    }
}

Este código se basa en http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//00010000047t000000.

Aquí está la excepción de los detalles de Visual C#'s de diálogo de error:

System.Runtime.InteropServices.COMException was unhandled
  Message="Error HRESULT E_FAIL has been returned from a call to a COM component."
  Source="ESRI.ArcGIS.Carto"
  ErrorCode=-2147467259
  StackTrace:
       at ESRI.ArcGIS.Carto.ImageServerLayerClass.Initialize(String ServiceURL)
       at EngineConsoleApplication1.Program.Main(String[] args) in C:\Users\brown\AppData\Local\Temporary Projects\EngineConsoleApplication1\Program.cs:line 35
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

2voto

saint_groceon Puntos 2696

Me gustaría probar el uso de ESRI.ArcGIS.RuntimeManager.Se unen antes de la licencia de inicialización, como se muestra aquí.

STAThread()] static void Main(string[] args)
{
    //Add runtime binding prior to any ArcObjects code in the static void Main() method.
    ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop);
    //ESRI License Initializer generated code.
    m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[]
    {
        esriLicenseProductCode.esriLicenseProductCodeArcView
    }
    , new esriLicenseExtensionCode[]{}
    );
    //ESRI License Initializer generated code.
    //********************************
    // Insert code here.
    //********************************
    //Do not make any call to ArcObjects after ShutDownApplication().
    m_AOLicenseInitializer.ShutdownApplication();
}

1voto

Vasu Puntos 11

Un par de cosas que usted puede intentar:

  • Asegúrese de arcGIS cuentas/grupos de permisos para la c:\temp\ carpeta y el fgdb.gdb archivo.
  • Asegúrese de que los componentes COM que existe en su máquina. Trate de volver a instalar el SDK de ArcObjects y/o ArcEngine. Parece que el objeto COM en cuestión podría no ser encontrado.
  • Con el fin de depurar, intentar aislar el código que está causando el error. A veces conseguir un mejor y más descriptivo de error.

1voto

blak3r Puntos 226

He resuelto este problema. Resulta que el JABÓN dirección debe ser utilizado, que en mi caso es http://vega/ArcGIS/services/grandcanyon/ImageServer?wsdl. He obtenido esta dirección por subir una carpeta (http://vega/ArcGIS/rest/services/grandcanyon/ImageServer) y haciendo clic en el "JABÓN" en la parte inferior. Usted también no necesita "?wsdl" sufijo al final de la dirección.

i-Ciencias.com

I-Ciencias es una comunidad de estudiantes y amantes de la ciencia en la que puedes resolver tus problemas y dudas.
Puedes consultar las preguntas de otros usuarios, hacer tus propias preguntas o resolver las de los demás.

Powered by:

X