tags:

views:

321

answers:

1

I am building SSAS cubes using AMO in c#. For this, I want to get a list of the public properties for the classes for Server, Cube, Dimension, etc. This will be my superset from which the user must provide mandatory properties and may provide the optional ones.

I am trying to generate an XSD schema. I ran the following command

XSD C:\windows\assembly\GAC_MSIL\Microsoft.AnalysisServices\10.0.0.0__89845dcd8080cc91\Microsoft.AnalysisServices.DLL /dataset /element:Cube /out:c:\temp\gac

and got this error

Error: There was an error processing 'C:\windows\assembly\GAC_MSIL\Microsoft.AnalysisServices\10.0.0.0__89845dcd8080cc91\Microsoft.AnalysisServices.DLL'.
  - There was an error reflecting type 'Microsoft.AnalysisServices.ModelComponent'.
  - Cannot serialize member 'System.ComponentModel.Component.Site' of type 'System.ComponentModel.ISite', see inner exception for more details.
  - Cannot serialize member System.ComponentModel.Component.Site of type System.ComponentModel.ISite because it is an interface.

What do I do so that the schema is properly generated?

+1  A: 

There are a few things i wondered about when reading this question:

  • Why have a /dataset option. This is only usefull when transforming an XSD into Code. You seem to be doing the (compiled)code into XSD. (dataset versus DTOc class generation)
  • Why have a /element option. This is only usefull when transforming an XSD into Code (Sub select the element(s) to generate code for, not all elements in the source schema)

Then, why the problem occurs is that this library contains types, which have public fields/properties with an interface type (ISite in this case).

The XmlSerializer cannot serialize interfaces, it needs concrete types. Hence the failure you are getting.

Goal is clear, but i´m afraid you will not be able to use the XSD.exe tool. Since one of your required objects (Cube) has a public property of the type ISite, this will always break the XMLSerializer.

I´m guessing your best bet is the AnalysisServices SDK (maybe they provide you this object model) or... (ouch) using reflection yourself on the types you want generated with a subset of the properties-fields leaving out any interface type.

Hope this helps,

Marvin Smit
question edited to add goal
Raj More