You first need to refer to C:\Program Files\microsoft.net\adomd.net\100\microsoft.analysisservices.adomdclient.dll
C:\Program Files\Microsoft SQL Server\100\sdk\assemblies\microsoft.analysisservices.dll
Reference source is Msdn:http://gallery.technet.microsoft.com/scriptcenter/6901ede5-5d59-4b1f-8f1b-df3c8e645048#content
--------------------------------------------------------------------------------------------------------------- ----------------------
Using Microsoft.analysisservices; Using Microsoft.AnalysisServices.Hosting;
string ConnStr; String olapservername; String olapdb; &N Bsp String olapcube; Olapservername = "HZSV008"; &nbs P olapdb = "Tajimasalessubject"; Olapcube = "Sales-themed analysis model"; CONNSTR = "Provider=msolap;data source=" + Olapservername + ";"; //initial catalog=adventure Works DW 2008R2; "; Server olapserver = new server (); Olapserver.connect (CONNSTR); Console.WriteLine ("ServerName:" + OL Apservername); //database foreach (Database olapdatabase in olapserver.databases) &N Bsp { if (olapdb = = "" | | OLAPDatabase.Name.ToString () = olapdb) { &NBSP ; Console.WriteLine ("DatabaseName:" + olapdatabase.name); &NB Sp //cube &NBS P foreach (Cube olapcubex in Olapdatabase.cubes) { if (Olapcube = = "" | | Olapcubex.name = = olapcube) { &NB Sp &NBSp Console.WriteLine ("CubeName:" + olapcubex.name); &NB Sp //cube dimension &N Bsp foreach (Cubedimension olapdimension in Olapcubex.di mensions) { Console.WriteLine ("Dimen Sionname: "+ olapdimension.name); &NB Sp Console.WriteLine (" attributes:"); &NBS P //dimension attribute &NBS P   foreach (CubeAttribute olapdimattribute in Olapdimen Sion. Attributes) { nbsp Console.WriteLine (" " + OLAPDimAttribute.Attribute.Name); &N Bsp } &NB Sp Console.WriteLine (" hierarchy:"); &nbs p; //dimens Ion hierarchy &NBSP foreach (Cubehierarchy olapdimhierarchy in olapdimension.hierarchies) &NB Sp { &N Bsp Console.WriteLine (" " + O LAPDimHierarchy.Hierarchy.Name); //dimension Hierarchy level &NBS P foreach (Level olapdimhierachylevel in Olapdi MHierarchy.Hierarchy.Levels) &NB Sp { &N Bsp &nBsp Console.WriteLine (" " + olapdimh Ierachylevel.name); &NBSP ; } &N Bsp } / &NBS P //measure group &NB Sp foreach (MeasureGroup olapmeasuregroup in olapcubex.measuregroups) { & nbsp Console.WriteLine ("Measure Group:" + OlapmeasuregrouP.name); &N Bsp Console.WriteLine ("Measures:"); / & nbsp //measures foreach (Measure olapmeasure in Olapmeasuregroup.measures) & nbsp / {&N Bsp , &NB Sp Console.WriteLine (" " + olapmeasure.name); &NBS P }   Console.WriteLine ("Measu Re Group Dimension: "); &NB Sp //Measure Group dimension foreach (Measuregroupdimension olapmeasuregroupdimension i n olapmeasuregroup.dimensions) + nbsp { &N Bsp Console.WriteLine (" " + Olapmeasuregroupdimens Ion. Cubedimension.name); &NBS P } &NB Sp Console.WriteLine ("Partition:"); //partitions &NBSP ; foreach (Partition olappartition in OL apmeasuregroup.partitions) &NBSP ; { &N Bsp Console.WriteLine (" " + olappartition.name); &n Bsp , }&N Bsp;&nBsp }  &NBS P } &N Bsp } &NB Sp } } }&NB sp; Console.readkey ();
C # ADOMD Connection analysis Service View Cube