How to define vertex declaration in Riemer XNA tutorial.

Been working through the updated MonoGame version and I’m getting the error System.NotImplementedException when it runs. After a Google I think the problem is normals and the VertexDeclaration but I’m lost. Can anyone help please?

        RasterizerState rs = new RasterizerState();
        rs.CullMode = CullMode.None;
        rs.FillMode = FillMode.WireFrame;
        device.RasterizerState = rs;

        effect.CurrentTechnique = effect.Techniques["ColoredNoShading"];

        effect.Parameters["xView"].SetValue(viewMatrix);
        effect.Parameters["xProjection"].SetValue(projectionMatrix);
        Matrix worldMatrix = Matrix.Identity;
        effect.Parameters["xWorld"].SetValue(worldMatrix);
        

        foreach (EffectPass pass in effect.CurrentTechnique.Passes)
        {
            pass.Apply();

            device.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertices, 0, vertices.Length, indices, 0, indices.Length / 3, VertexPositionColor.VertexDeclaration);
        }

It would be useful to know where the exception is happening. You should be able to get a stacktrace.

Does the ColoredNoShading technique need normals? The NoShading part indicates that it doesnt, but if it does, then VertexPositionColor.VertexDeclaration won’t work, because that only includes position and color, no normals.

This is how I did it in Riemers Series 3D 3 HLSL overview
(Windows/Visual Studio 2019 Community/XNA 4.0)

namespace XNAseries3
{
public struct MyOwnVertexFormat
{
public Vector3 Position;
private Vector2 TexCoord;
private Vector3 Normal;

    public MyOwnVertexFormat(Vector3 position, Vector2 texCoord, Vector3 normal)
    {
         this.Position = position;
         this.TexCoord = texCoord;
         this.Normal = normal;
    }

    public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration
    (
        new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
        new VertexElement(sizeof(float) * 3, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0),
        new VertexElement(sizeof(float) * (3 + 2), VertexElementFormat.Vector3, VertexElementUsage.Normal, 0)
    );

}
//…

    foreach (EffectPass pass in effect.CurrentTechnique.Passes)
    {
        pass.Apply();
        device.SetVertexBuffer(vertexBuffer);
        device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, MyOwnVertexFormat.VertexDeclaration.VertexStride);
    }

BTW
I would change this:
rs.FillMode = FillMode.WireFrame;
to:
rs.FillMode = FillMode.Solid;

// Here’s an example of IVertexType implementation
public struct VertexPositionNormalTangentBinormalTexture : IVertexType
{
public Vector3 Position;
public Vector3 Normal;
public Vector2 TextureCoordinate;
public Vector3 Tanget;
public Vector3 Binormal;

public static readonly VertexElement[] VertexElements = new VertexElement[] 
{
    new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
    new VertexElement(12, VertexElementFormat.Vector3, VertexElementUsage.Normal, 0),
    new VertexElement(24, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0),
    new VertexElement(32, VertexElementFormat.Vector3, VertexElementUsage.Tangent, 0),
    new VertexElement(44, VertexElementFormat.Vector3, VertexElementUsage.Binormal, 0)
};

public static readonly VertexDeclaration MyVertexDeclaration = new VertexDeclaration(VertexElements);

// (enables implementation of IVertexType)
public VertexDeclaration VertexDeclaration
{
    get { return MyVertexDeclaration; }
}

public static readonly int SizeInBytes = sizeof(float) * (3 + 3 + 2 + 3 + 3);

}

// now the custom type can be used:
// typeof(VertexPositionNormalTangentBinormalTexture)