AutoCad2010 with Visualstudio-2008 (c#)

AutoCad2010 with Visualstudio-2008 (c#)

giskumar
Enthusiast Enthusiast
2,238 Views
4 Replies
Message 1 of 5

AutoCad2010 with Visualstudio-2008 (c#)

giskumar
Enthusiast
Enthusiast

Hi All,

 

I tried to write a simple program in c#.net for autocad 2010.

I build and loaded the .dll file but not able to access the command.

When i type tst in command prompt, it prompting unknown command.

Please help  me how to solve this.

 

using System;
using System.Collections.Generic;
using System.Text;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data;

namespace AcadGlobles
{
    class Commands
    {
        [CommandMethod("tst")]
        static public void test()
        {
            MessageBox.Show("hi");
        }
    }
}

 

 

 Thanks,

Kumar.

0 Likes
Accepted solutions (3)
2,239 Views
4 Replies
Replies (4)
Message 2 of 5

Alexander.Rivilis
Mentor
Mentor
Accepted solution

It is look like you do not assign Copy Local to False for AutoCAD DLL references in your solution (acmgd.dll, acdbmdg.dll, etc.)

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 3 of 5

Jeff_M
Consultant
Consultant
Accepted solution

The class Commands needs to be public. Not sure if it matters, but normally the public is the first item listed, so instead of

static public void test()

it woul be

public static void test()

Jeff_M, also a frequent Swamper
EESignature
Message 4 of 5

augusto.goncalves
Alumni
Alumni
Accepted solution

Like Jeff said, the method and the class must be public, otherwise AutoCAD will not locate the method

 

class Commands

 

should be replaced with

 

public class Commands

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
Message 5 of 5

giskumar
Enthusiast
Enthusiast

Hi All,

 

Thanks for the reply.

 

Adding Public before class is working for me.

 

Regards,

Kumar.

0 Likes