I am working in .NET Framework and am using C#. I am referencing external dlls. One particular method in available only if the dlls version is 12 or up. Is there a way to condition code compilation based on the version of dlls.
I can get the version of the dlls, but if it is on version 11 or lower, how can I restrict a chuck of code from compiling.
Below is the code I'm currently using, when I refer dlls of version 11 or lower, the GetUnsortedFaces()
shows error and it won't let me compile.
List<IVctFace> IVctEdge.AllFaces()
{
Face[] faces;
Version version = System.Reflection.Assembly.GetAssembly(typeof(Edge)).GetName().Version;
faces = this.Edge.GetFaces();
if (version.Major > 11)
{
faces = this.Edge.GetUnsortedFaces();
}
List<IVctFace> vctFaces = new List<IVctFace>();
foreach (Face face in faces)
{
vctFaces.Add(new VctFace(face, this.Parent.Parent));
}
return vctFaces;
}
I do know about #define
but they needs to be created outside the namespace.