.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

2010 dotNET Wizards

7 REPLIES 7
Reply
Message 1 of 8
drauckman
1220 Views, 7 Replies

2010 dotNET Wizards

When you use the wizard to create a project you end up with myCommands.cs and myPlugin.cs. I can empty all the existing code out of myPlugin.cs and program in a custom class, however if you build and try to run the code AutoCAD says that it cannot find a function by the name I called it.

If I move this function into myCommands.cs then it will work fine. I thought you can have as many cs files as you want and they end up getting linked all into the same dll? Why can I not access commands written in the myPlugin.cs file?
7 REPLIES 7
Message 2 of 8
arcticad
in reply to: drauckman

Did you make a new instance of your class in the other file?
---------------------------



(defun botsbuildbots() (botsbuildbots))
Message 3 of 8
Anonymous
in reply to: drauckman

I don't use the wizards and advise others to not use them,
mainly because Visual Studio project and item templates
are just as easy to use and can be easily customized to
include commonly-used items.

Anyway, the problem you have is the CommandClass
attribute.

When you use this attribute with any class in an assembly,
the managed runtime assumes that only classes which the
attribute is used with expose command methods. So, to
add commands to another class, you must also use the
CommandClass attribute just as it's used with the wizard-
generated class.

[assembly: CommandClass( typeof( MyCommandClass ) )]

where 'MyCommandClass' is the class that exposes one
or more command methods. You can repeat this attribute
for every class that exposes command methods, and you
generally do that at the top of the code file containing the
class.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6300742@discussion.autodesk.com...
When you use the wizard to create a project you end up with myCommands.cs
and myPlugin.cs. I can empty all the existing code out of myPlugin.cs and
program in a custom class, however if you build and try to run the code
AutoCAD says that it cannot find a function by the name I called it.

If I move this function into myCommands.cs then it will work fine. I
thought you can have as many cs files as you want and they end up getting
linked all into the same dll? Why can I not access commands written in the
myPlugin.cs file?
Message 4 of 8
drauckman
in reply to: drauckman

Thank you for clearing that up for me. I guess where my confusion comes from is that the line that you refer to has the comment that the line is not mandatory, but improves loading performance. It seems that if you remove that line then your commands are not available in AutoCAD, why would that comment be in the wizard generated file?
Message 5 of 8
Anonymous
in reply to: drauckman

The CommandClass attribute is optional, but on an assembly-
wide basis. IOW, you either do not use it at all, or you must use
it on every class that exposes commands. Using it on some
classes that expose commands but not on all of same defeats
the purpose of the attribute, which is to eliminate the need for
the runtime to search every class to find command methods.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6301195@discussion.autodesk.com...
Thank you for clearing that up for me. I guess where my confusion comes
from is that the line that you refer to has the comment that the line is not
mandatory, but improves loading performance. It seems that if you remove
that line then your commands are not available in AutoCAD, why would that
comment be in the wizard generated file?
Message 6 of 8
drauckman
in reply to: drauckman

I am continuing to have problems with the whole CommandClass setup. I have 2 cs files in my project, and each of them have a different namespace. If i use the CommandClass attribute in both of these I get an error when trying to load in AutoCAD 2011 that states there is an error eDuplicateKey and it cannot load the assembly, however I can run the command in one of the .cs files but not the other, so it must stop loading after the first file. If I get rid of these attributes then this error goes away but the command that ran does not run anymore and now the one in the other file runs.

Is there a limit of only being able to put CommandMethods in one .cs file only? I cannot get two .cs files with different commands and namespaces to work.

I have checked and double checked and I cannot see ANY duplication in any namespaces, command names, function names, class names etc. so why is this eDuplicateKey error being thrown when there is nothing duplicated in any file?
Message 7 of 8
Anonymous
in reply to: drauckman

eDuplicateKey means that you're defining a command
with the same name more than once.

Namespaces are irrelevant, it's the name of the command
that must be unique (or you must use a different groupname
for one of them).

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2011

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6383332@discussion.autodesk.com...
I am continuing to have problems with the whole CommandClass setup. I have 2 cs
files in my project, and each of them have a different namespace. If i use the
CommandClass attribute in both of these I get an error when trying to load in
AutoCAD 2011 that states there is an error eDuplicateKey and it cannot load the
assembly, however I can run the command in one of the .cs files but not the
other, so it must stop loading after the first file. If I get rid of these
attributes then this error goes away but the command that ran does not run
anymore and now the one in the other file runs.

Is there a limit of only being able to put CommandMethods in one .cs file only?
I cannot get two .cs files with different commands and namespaces to work.

I have checked and double checked and I cannot see ANY duplication in any
namespaces, command names, function names, class names etc. so why is this
eDuplicateKey error being thrown when there is nothing duplicated in any file?
Message 8 of 8
drauckman
in reply to: drauckman

You were right, I had a duplicate command buried in my code that had nothing in it, I must have copied it to another file to work on and did not erase the original command method.

Thanks!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost