You cannot call a .NET method inside a conditional code block if that method calls back into PowerScript functions.