how to call another class with C#

how to call another class with C#

a.kouchakzadeh
Advocate Advocate
869 Views
4 Replies
Message 1 of 5

how to call another class with C#

a.kouchakzadeh
Advocate
Advocate

Hi every one.

I have right clicked on my project, added another class, assigned a command method to it, but after I loaded it, the method isnt available. am I missing any thing?

0 Likes
Accepted solutions (1)
870 Views
4 Replies
Replies (4)
Message 2 of 5

_gile
Consultant
Consultant

Hi,

Diffucult to diagnose without seeing any code.

Anyway,

  • a class defining commands must be a 'public' class as the methods decored with the CommandMethod have to be 'public' ;
  • if the project contains a class decored with the attribute: [assembly: CommandClass(typeof(...))], all the classes in the same project have to decored with a similar attribute.


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 5

a.kouchakzadeh
Advocate
Advocate

I think I couldn't describe the issue good enough. my bad

Ill try to explain with this picture

CleanBlock has 2 classes. one is "CreateSSet". and the Other is "test"

when I load the dll file, the command method "nsvtest" does not work.

I mean it doesnt event show up in the command line. am I missing some thing ?

 

code.JPG

 

0 Likes
Message 4 of 5

_gile
Consultant
Consultant
Accepted solution

As I said upper the class where commands are defined have to be public:

public class test
{
    [CommandMethod("nsvtest")]
    // ...
}

It looks like you are missing some .NET/C# basics.

IMHO, you should not try to program AutoCAD with .NET while you are not comfortable with .NET and C# basics that you may learn outside of AutoCAD.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 5 of 5

a.kouchakzadeh
Advocate
Advocate

thank you sir. I didnt pay attention to the class. I was looking at the public void NSVtest()

that is true. Not having a solid background in C# and .NEt is being a challenge. unfortunately I have a limited time for migrating from VBA to .NET and rewriting my programs.

0 Likes