title: C# - OpenGl.Net shaders fail to compile with no errors
body: <p>I am using C# and OpenGL.Net to make a simple program to display a triangle, but for some reason the program runs and leaves the screen blank. It says that both the vertex and fragment shaders failed to compile, but there is no error list.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Threading.Tasks;
  using System.Threading;
  using System.Text;
  
  using SFML;
  using SFML.Graphics;
  using SFML.Window;
  using OpenGL;
  
  using System.Media;
  using System.IO;
  
  namespace SFML_Test
  {
      static class Program
      {
          static void Main()
          {
              // Create the main window
              ContextSettings settings = new ContextSettings
              {
                  DepthBits = 24,
                  StencilBits = 8,
                  AntialiasingLevel = 2 // optional
              };
              RenderWindow window = new RenderWindow(new VideoMode(800, 600), "SFML Works!");
              window.Closed += new EventHandler(OnClose);
  
              Color windowColor = new Color(0, 0, 0);
              // Setup
              uint vao = Gl.GenVertexArray();
              Gl.BindVertexArray(vao);
  
              float[] trianglePoints = 
                  { -0.5F, -0.5F,
                  0.5F, -0.5F,
                  0F, 0.5F};
              uint vbo = Gl.GenBuffer();
              Gl.BindBuffer(BufferTarget.ArrayBuffer, vbo);
              Gl.BufferData(BufferTarget.ArrayBuffer, (uint)(4*trianglePoints.Length), trianglePoints, BufferUsage.StaticDraw);
              SetupVertexShader();
  
              Gl.EnableVertexAttribArray(0);
              Gl.BindBuffer(BufferTarget.ArrayBuffer, vbo);
              Gl.VertexAttribPointer(0, 3, VertexAttribType.Float, false, 0, (IntPtr)0);
              Gl.DrawArrays(OpenGL.PrimitiveType.Triangles, 0, 3);
              // Start the game loop
              while (window.IsOpen())
              {
                  window.DispatchEvents();
                  window.Clear(windowColor);
                  Gl.DrawElements(OpenGL.PrimitiveType.Triangles, 3, DrawElementsType.UnsignedInt, 0);
  
                  Thread.Sleep((1/30) * 1000);
                  window.Display();
              }
          }
          static void SetupVertexShader()
          {
              uint vertexShader = Gl.CreateShader(ShaderType.VertexShader);
              string[] shaderString = File.ReadAllLines(@".\Shaders\vertex.shader");
              Gl.ShaderSource(vertexShader, shaderString);
              Gl.CompileShader(vertexShader);
              int success;
              Gl.GetShader(vertexShader, ShaderParameterName.CompileStatus, out success);
              if (success != 0)
              {
                  Console.WriteLine("Vertex Creation Success.");
              }
              else
              {
                  Console.WriteLine("Vertex creation fail.");
                  Gl.GetShader(vertexShader, ShaderParameterName.InfoLogLength, out int logLength);
                  int logMaxLength = 1024;
                  StringBuilder infoLog = new StringBuilder(logMaxLength);
                  Gl.GetShaderInfoLog(vertexShader, 1024, out int infoLogLength, infoLog);
                  Console.WriteLine("Errors: \n{0}", infoLog.ToString());
              }
              uint fragmentShader = Gl.CreateShader(ShaderType.FragmentShader);
              Gl.ShaderSource(fragmentShader, File.ReadAllLines(@".\Shaders\fragment.shader"));
              Gl.CompileShader(fragmentShader);
              Gl.GetShader(fragmentShader, ShaderParameterName.CompileStatus, out success);
              if (success != 0)
              {
                  Console.WriteLine("Fragment Creation Success.");
              }
              else
              {
                  Console.WriteLine("Fragment creation fail.");
                  Gl.GetShader(fragmentShader, ShaderParameterName.InfoLogLength, out int logLength);
                  int logMaxLength = 1024;
                  StringBuilder infoLog = new StringBuilder(logMaxLength);
                  Gl.GetShaderInfoLog(vertexShader, 1024, out int infoLogLength, infoLog);
                  Console.WriteLine("Errors: \n{0}", infoLog);
              }
              uint shaderProgram = Gl.CreateProgram();
              Gl.AttachShader(shaderProgram, vertexShader);
              Gl.AttachShader(shaderProgram, fragmentShader);
              Gl.BindFragDataLocation(shaderProgram, 0, "outColor");
              Gl.LinkProgram(shaderProgram);
              Gl.UseProgram(shaderProgram);
          }
          static void OnClose(object sender, EventArgs e)
          {
              // Close window
              RenderWindow window = (RenderWindow)sender;
              window.Close();
          }
      }
  }
  </code></pre>
  
  <p>Here is vertex.shader:</p>
  
  <pre><code>#version 150 core
  
  in vec2 position;
  
  void main()
  {
      gl_Position = vec4(position, 0.0, 1.0);
  }
  </code></pre>
  
  <p>And here is fragment.shader:</p>
  
  <pre><code>#version 150 core
  out vec4 outColor;
  void main()
  {
      outColor = vec4(1.0, 1.0, 1.0, 1.0);
  }
  </code></pre>
  
  <p><strong>EDIT:</strong>
  As suggested by <a href="https://stackoverflow.com/users/161554/luca" title="Luca">Luca</a> (Thank you) I added Gl.Initialize() before everything 
  else. I also removed <code>core</code> from the preprocessor directive, and now the shaders compile with this error:</p>
  
  <pre><code>WARNING: 2:1: invalid profile specified
  ERROR: 2:1: '' : syntax error: #version
  ERROR: 2:1: '' : syntax error: unexpected tokens following preprocessor 
  directive - expected a newline
  </code></pre>
  
  <p>Any help?</p>