0

My code keeps throwing an NotSuppportedException at the Console.WindowHeight line.

I was wondering why and what I could do to fix it?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

static int firstPlayerPadSize = 10;
static int secondPlayerPadSize = 4;
static int ballPositionX = 0;
static int ballPositionY = 0;
static bool ballDirectionUp = true; //Determines if the ball direction is up

static bool ballDirectionRight = false;
static int firstPlayerPosition = 0;
static int secondPlayerPosition = 0;
static int firstPlayerResult = 0;
static int secondPlayerResult = 0;
static Random randomGenerator = new Random();
//***************
//START MODEL
//*****************
public void Screen()
{
    Console.ForegroundColor = ConsoleColor.Yellow;
    Console.BufferHeight = Console.WindowHeight;
    Console.BufferWidth = Console.WindowWidth;
}

error message that is showing up

  • What is C about this? – Yunnosch Dec 14 '17 at 17:37
  • Well, er, that command is not supported on your system. Seems fairly clear to me. Also, why have you tagged `c`? – DavidG Dec 14 '17 at 17:38
  • Maybe his computer's compiler runs a half-step below normal (for my fellow musicians) – Christian Gibbons Dec 14 '17 at 17:39
  • The error message is pretty clear: this is not supported (on your OS/machine/whatever). If you read the details of the exception, you may find out if it's really `WindowHeight` or rather `BufferHeight` that throws. – René Vogt Dec 14 '17 at 17:42
  • 1
    You cannot use this property if your program does not have a console. Could be a GUI app, could be a console mode app whose output got redirected. So at a minimum you want to check Console.IsOutputRedirected. Well, not in a game I'd assume, beware of copy/paste code. – Hans Passant Dec 14 '17 at 17:42
  • what command would I use instead it worked on windows before? – dead.grateful Dec 14 '17 at 17:43
  • Check this https://stackoverflow.com/questions/12520753/setting-system-console-windowheight-throws-an-system-notsupportedexception-under – Neeraj Kumar Dec 14 '17 at 17:44
  • could you post the libraries you are using? It seems that your IDE does not support that method. – Fabulous Dec 14 '17 at 17:44
  • @Fabulous here are the libraries using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; – dead.grateful Dec 14 '17 at 18:08

0 Answers0