In the process of creating/repairing meshes, at some point Mesh.MatchEdges() can produce an invalid mesh. If this happens, trying to add it to the document via scriptcontext.doc.Objects.AddMesh(mesh) fails.
If I add the mesh to the document before MatchEdges() and then run the Rhino command MatchMeshEdges on it, it produces the bad object as well - but at least I have it in the document and can do something with it. Any way to get an invalid mesh added to the document via RhinoCommon?
Also, there is an overload when adding a mesh that has a boolean requireValidMesh. This can be set to false, and other variables can (probably) be set to null/None.