Invalid Cast MeshingParameters >> MeshingParameters

hello,

I want to wrap Mesh.CreateFromBrep(brep, settings); into a new component with some more stuff going on and ran into the following error:
image

Relevant code:

        protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
        {
            pManager.AddBrepParameter("Brep", "B", "Brep to mesh", GH_ParamAccess.item);
            pManager.AddGenericParameter("Settings", "S", "Mesh settings", GH_ParamAccess.item);
        }


        protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
        {
            pManager.AddMeshParameter("Mesh", "M", "Mesh", GH_ParamAccess.item);
        }



        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Brep brep = null;
            MeshingParameters settings = null;

            if (!DA.GetData(0, ref brep)) { return; }
            if (!DA.GetData(1, ref settings)) { return; }
        }

The error is thrown with in the second GetData().

The only somehow related post I could find is this one: Invalid Cast Brep > Brep - Grasshopper Developer - McNeel Forum
There is no copy of any library in my bin folder, which rules out that solution.

I appreciate any help on this.

Cheers,
Bernd

What if settings was defined as object? What’s the type of the data you get out then?

var settings = default(object);
DA.GetData(1, ref settings);
Rhino.RhinoApp.WriteLine(settings.GetType().FullName);

That’s Grasshopper.Kernel.Types.GH_MeshingParameters.
I’m still learning how to deal with types in GH, so not sure how to deal with this one.

Edit: To add to this, I’m using the default Mesh settings components, that ship with GH, if that wasn’t clear.