Code Red > .NET

CommandMethod not recognized

(1/2) > >>

mastrolube:
Hello everyone!
I've a problem running .dll I made.. I'm following a course on udemy, but for me it doens't load anything.. Anyone can tell me what's the problem?
I've a solution with that class:

--- Code: ---using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
[code]
namespace ControlsDemo
{
    class ControlsDemoUtil
    {
        [CommandMethod("Test")]
        public void Demo()
        {
            MainForm mf = new MainForm();
            mf.Show();
        }
    }
}
--- End code ---

when I load the DLL with netload, keyword "Test" is not recognized (It's not even there!)
I compiled using as references AcCoreMgd, AcDbMgd and AcMgd with version 23.1 (I'm running Autocad 2020)
I don't understand what I'm missing, I already did a DLL following the AutoCAD tutorial and this worked just fine (it was a while ago..).
I don't get where this simple few rows code fails.. If I don't find out Iill not able to go ahead with the tutorial .... :(

huiz:
Your class should be public, I think.

Hanauer:
Did you select the correct .NET version?
For AutoCAD 2020: .NET Framework 4.7.

CADbloke:
@huiz is right. A class is internal by default unless you declare it public. Command classes and methods must be public. The public method in the internal class can only be internal, its access is restricted by the access level of the class.

Bryco:
[assembly: CommandClass(typeof(ControlsDemo.class ControlsDemoUtil))]


I run commands from an internal class but I do have the command class which the code above appears to be missing
namespace cnc
{
    internal class Cnc
    {

Navigation

[0] Message Index

[#] Next page

Go to full version