Getting ArgumentNullException in SpriteBatch.End()

I switched my Project from XNA 4 to MonoGame 2.5.1. The port went somewhat unproblematic but I am stumpled across a problem i can’t resolve. For your interest, the code worked on XNA:

When I am drawing a spritebatch with a basicEffect I get an ArgumentNullException on calling the End() method. This is the simplified draw call

// polyEffTest is defined somewhere else, not in the draw function
polyEffTest = new PolygonBasicEffect(gd);  

// the simplified draw call
sbTest.Begin(
  SpriteSortMode.BackToFront,
  BlendState.AlphaBlend,
  SamplerState.LinearClamp,
  DepthStencilState.Default,
  GraphicsDevice.RasterizerState,
  polyEffTest,
  Matrix.CreateTranslation(offX, offY, 0f)
);

// draw something [...]

sbTest.End() // <- End-call causes Exception

when I replace polyEffTest with NULL in sbTest.Begin I won’t get the ArgumentNullException but nothing gets drawed either (obvious). So I guess it has to do something with the BasicEffect.

  at OpenTK.Graphics.ES11.GL.GetError () [0x00000] in <filename unknown>:0 
  at OpenTK.Graphics.ES11.ErrorHelper.ResetErrors () [0x00000] in <filename unknown>:0 
  at OpenTK.Graphics.ES11.ErrorHelper..ctor (IGraphicsContext context) [0x00000] in <filename unknown>:0 
  at OpenTK.Graphics.ES11.GL.Viewport (Int32 x, Int32 y, Int32 width, Int32 height) [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.Graphics.GLStateManager.Viewport (Rectangle viewport) [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.Graphics.BasicEffect.Apply () [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.Graphics.SpriteBatch.End () [0x00000] in <filename unknown>:0 
  at Hello.Game1.Draw (Microsoft.Xna.Framework.GameTime gameTime) [0x00058] in /home/mereddyn/projects/c#/Hello/Hello/Game1.cs:97 
  at Microsoft.Xna.Framework.Game.DoDraw (Microsoft.Xna.Framework.GameTime gameTime) [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.GameWindow.OnRenderFrame (System.Object sender, OpenTK.FrameEventArgs e) [0x00000] in <filename unknown>:0 
  at OpenTK.GameWindow.OnRenderFrame (OpenTK.FrameEventArgs e) [0x00000] in <filename unknown>:0 
  at OpenTK.GameWindow.OnRenderFrameInternal (OpenTK.FrameEventArgs e) [0x00000] in <filename unknown>:0 
  at OpenTK.GameWindow.RaiseRenderFrame (System.Diagnostics.Stopwatch render_watch, System.Double& next_render, OpenTK.FrameEventArgs render_args) [0x00000] in <filename unknown>:0 
  at OpenTK.GameWindow.DispatchUpdateAndRenderFrame (System.Object sender, System.EventArgs e) [0x00000] in <filename unknown>:0 
  at OpenTK.GameWindow.Run (Double updates_per_second, Double frames_per_second) [0x00000] in <filename unknown>:0 
  at OpenTK.GameWindow.Run (Double updateRate) [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.GameWindow.Run (Double updateRate) [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.LinuxGamePlatform.RunLoop () [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.Game.Run (GameRunBehavior runBehavior) [0x00000] in <filename unknown>:0 
  at Microsoft.Xna.Framework.Game.Run () [0x00000] in <filename unknown>:0 
  at Hello.Program.Main () [0x00010] in /home/mereddyn/projects/c#/Hello/Hello/Program.cs:20 

I am using MonoGame 2.5.1 on Ubuntu 14.04 with MonoDevelop. The polyEffTest is defined like that:

public class PolygonBasicEffect : BasicEffect
{
    public PolygonBasicEffect(GraphicsDevice graphicsDevice)
        : base(graphicsDevice)
    {
        this.VertexColorEnabled = true;
        this.TextureEnabled = true;
        this.Projection = Matrix.CreateOrthographicOffCenter(
            0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height, 0, 0, 1
        );
    }

    public PolygonBasicEffect(BasicEffect effect)
        : base(effect)
    {
    }

    public BasicEffect Clone()
    {
        return new PolygonBasicEffect(this);
    }
}

Even if I am calling the End call imediatly after the Begin i get the Exception. I even get the exception if I am replacing polyEffTest with a new BasicEffect()

I was testing this on a different machine. I downloaded the same MonoVersion to a Windows 7 System and tried it with VisualStudio. There the code worked. I even tried to enable unsafe code, it still does not work.

Any reason why you are using 2.5 and not the latest? This is expected to work fine.

Yes, 2.5.1 is the latest version in the repository. Also Mono 3.x is not in the repository.

Well, I kinda mixed the version numbers. I have installed MonoGame 2.5.1 as it was the latest version available in my repo. It autom. installed MonoDevelop 4.x

The whole time i thought Mono 2.x was the latest available in my repo, but in fact i have Mono 3.2x installed, this comes as i wanted to load the MonoGame 3.0.1 mpack into MonoDevelop and it told me that he can’t use it because Core v3 was missing. I thought Core v3 was meant to be Mono and could not find any never version as the one I got installed, so i assumed i had Mono 2.x installed.

Now I am aware, that with Core v3 MonoDevelop was meant. But I already got MonoDevelop 4, i never thought, that it could not be backwards compatible. So, to use MonoGame 3.0.1 i need to downgrade my IDE to Version 3. I guess i just wait until MonoGame 3.2 packages are available for Linux. I hope my problem will be solved with a never version.

I got it to work. I updated all Versions and build the Assembly from Source and invoked the DLLs. Now it works as expected.