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
and we also have this
{
[Flags]
public enum UpdateOptions
{
Default = 0,
ExpandFull = 1,
AlterDependents = 2,
}
}
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!