.NET

Reply
Active Contributor
giskumar
Posts: 44
Registered: ‎12-06-2010
Message 1 of 5 (567 Views)
Accepted Solution

AutoCad2010 with Visualstudio-2008 (c#)

567 Views, 4 Replies
04-26-2012 04:17 AM

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.

Moderator
Alexander.Rivilis
Posts: 1,398
Registered: ‎04-09-2008
Message 2 of 5 (559 Views)

Re: AutoCad2010 with Visualstudio-2008 (c#)

04-26-2012 05:08 AM in reply to: giskumar

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


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

*Expert Elite*
Jeff_M
Posts: 4,227
Registered: ‎07-22-2003
Message 3 of 5 (550 Views)

Re: AutoCad2010 with Visualstudio-2008 (c#)

04-26-2012 06:34 AM in reply to: giskumar

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
ADN Support Specialist
augusto.goncalves
Posts: 312
Registered: ‎04-30-2009
Message 4 of 5 (540 Views)

Re: AutoCad2010 with Visualstudio-2008 (c#)

04-26-2012 08:32 AM in reply to: giskumar

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
Autodesk Developer Network
Active Contributor
giskumar
Posts: 44
Registered: ‎12-06-2010
Message 5 of 5 (516 Views)

Re: AutoCad2010 with Visualstudio-2008 (c#)

04-26-2012 09:30 PM in reply to: giskumar

Hi All,

 

Thanks for the reply.

 

Adding Public before class is working for me.

 

Regards,

Kumar.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community