husseinsayed

Problem with ArcObjects and Visual studio 2010 c#

Discussion created by husseinsayed on Oct 27, 2011
Latest reply on Oct 31, 2011 by husseinsayed
I'm getting started with ArcObject and i'm trying to build a console application that reads mdb file and shows it's contents but i have been working in it for a long time and i don't know what is the problem that i'm facing i'm using
-windows server 2008 sp2
-VS 2010 C#
-ArcGis 10.0 licence Type:ArcInfo
-ArcSDK 10
My code is as following
using System;
using System.Collections.Generic;
using System.Text;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geodatabase;
namespace DesktopConsoleApplication1
{
    class Program
    {
        [STAThread()]
        static void Main(string[] args)
        {

            IWorkspace iws;
            iws = AccessWorkspaceFromPath(@"C:\GD\Test.mdb");
        }
        public static IWorkspace AccessWorkspaceFromPath(String path)
        {
            //ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop);

            IWorkspaceFactory workspaceFactory = new ESRI.ArcGIS.DataSourcesFile.ArcInfoWorkspaceFactoryClass();
            // Get FeatureClass to be set as datasource
            IWorkspace workspace = workspaceFactory.OpenFromFile(path, 0);
            return workspace;
        }
        
    }
}

when i us this code it give this error :
Retrieving the COM class factory for component with CLSID {1D887452-D9F2-11D1-AA81-00C04FA33A15} failed due to the following error: 80040111.

and when activating this line
ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop);
it gives me this error :
Error HRESULT E_FAIL has been returned from a call to a COM component.

Please any one can help me to solve this problem.
Thank you.

Outcomes