-2

I have two projects P1 and P2 (ClassLibrary projects). I added P2 to references of P1 . I need get method from P1 in P2 project.

I try do this something like:

//P1 project class Commands

 class Commands:ICommands
 {
    public void Somemethod()
    {......}
 }
 //P2 project
 interface ICommands
 {
  void Somemethod(); 
 }
 class UserControl1:UserControl
 {
  ICommands _commands
  public void setCommands(ICommands com)
  {
   _commands=com;
  }
  private void button1_Click(object sender, EventArgs e)
    {

        _commands.Somemethod();


    }
 }

But when i press on button1 i have exception :

Object reference not set to an instance of an object.

This is autoCad plugin. P1 load palette from P2, but commands for palette buttons are in P1 project.

When AutoCad run, palette load. This error have place when i press button and try call Somemethod(); All error text:

Unhandled exception has occurred in a component in your application. If you click Continue, the application will ignore this error and attempt to continue. Object reference not set to an instance of an object.

Somemethod() must run new drawing in AutoCad AutoCad Use only one dll (P1 project) UI palette load from second dll (P2 project) And i need for palette load method from first .dll (P1 project)

1 Answers1

0

At P1 define a class with static methods

From P2 (already loaded on AutoCAD), load P1, then call P1 Class.Method()

Augusto Goncalves
  • 8,493
  • 2
  • 17
  • 44