Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# error: Type 'x' already defines a member called 'y' with the same parameter types

Tags:

c#

On Visual C# Express, I get the following error with the code below:

'Type 'myComponent.SettingsComponent' already defines a member called 'SolveInstance' with the same parameter types'

But I only used SolveInstance there. What am I doing wrong and how would I be able to solve this on my own next time?

namespace myComponent
{
    public class SettingsComponent : GH_Component
    {
        protected override void SolveInstance(IGH_DataAccess DA)
        {
        }

        protected override void  RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
        {
        }

        protected override void SolveInstance(IGH_DataAccess DA)
        {
            if (m_settings == null)
            {
                AddRuntimeMessage(warning, "You must declare some valid settings");
                return;
            }
            DA.SetData(0, m_settings);
        }
    }
}
like image 657
Arthur Mamou-Mani Avatar asked Jan 16 '23 00:01

Arthur Mamou-Mani


2 Answers

It looks like you have two instances of

protected override void SolveInstance(IGH_DataAccess DA)

in your example class, one with an empty body and one with code.

like image 170
Jeff Cuscutis Avatar answered Jan 30 '23 12:01

Jeff Cuscutis


Try to find all occurences of SolveInstance in the project. You will possibly find another definition of this method in a .designer.cs file. They are autogenerated and sometimes they cause duplicity problems.

like image 42
ederbf Avatar answered Jan 30 '23 11:01

ederbf