joe
joe

Reputation: 61

Function call in another namespace and class

I like to connect the DLL (which contains namespace Chart) and call the subroutine public Simple() from the second class (namespace WinApp2). There is a error:

couldn't find type or namespace name Simple

Although I consider a reference and put using Chart and created a instance in the second namespace.

namespace Chart
{
    public partial class Simple : Form
    {
        Manage _mProject;
        public Simple()
        {
            InitializeComponent();
            _mProject = new Manage();
            _mProject.Add(new Task() { Name = "New Task" });
            _mChart.Init(_mProject);
        }
    }
}

using Chart;
namespace WinApp2
{
    public partial class Form4 : Form
    {
        Form2 fh;
        public Form4(Form2 aufrufer)
        {
          fh = aufrufer;
          InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
          var instance = new Simple();   (error !!!)
          instance.Simple();
        }
    }
}

Upvotes: 1

Views: 10662

Answers (1)

JustAPup
JustAPup

Reputation: 1780

What do you mean by "consider a reference and put using Chart" ? Did you actually include the dll in References section, or did you put using Chart and think that will reference the relevant dll?

The proper steps are:

  • Right click References section in VS
  • Choose Add Reference
  • Browse to location of relevant dll, choose OK

Another cause may be that Chart is a defined class in System.Web.DataVisualization.dll, so VS is confused. Try changing your Chart namespace to something else, e.g., MyChart

Hope this helps..

Upvotes: 1

Related Questions