Pass enum value to method which is called by dynamic object
- by user329588
hello.
I'm working on program which dynamically(in runtime) loads dlls.
For an example: Microsoft.AnalysisServices.dll.   
In this dll we have this enum:
namespace Microsoft.AnalysisServices
{
    [Flags]
    public enum UpdateOptions
    {
        Default = 0,
        ExpandFull = 1,
        AlterDependents = 2,
    }
}
and we also have this class Cube:
namespace Microsoft.AnalysisServices
{
    public sealed class Cube : ...
    {
        public Cube(string name);
        public Cube(string name, string id);
..
..
..
    }
}
I dynamically load this dll and create object Cube. Than i call a method Cube.Update(). This method deploy Cube to SQL Analysis server. But if i want to call
this method with parameters Cube.Update(UpdateOptions.ExpandFull) i get error, because method doesn't get appropriate parameter. 
I have already tried this, but doesn't work:
 dynamic updateOptions = AssemblyLoader.LoadStaticAssembly("Microsoft.AnalysisServices", "Microsoft.AnalysisServices.UpdateOptions");//my class for loading assembly
Array s = Enum.GetNames(updateOptions);
dynamic myEnumValue = s.GetValue(1);//1 = ExpandFull
dynamicCube.Update(myEnumValue);// == Cube.Update(UpdateOptions.ExpandFull) 
I know that error is in parameter myEnumValue but i don't know how to get dynamically  enum type from assembly and pass it to the method. Does anybody know the solution?
Thank you very much for answers and help!