Author Topic: Problem with "Extension of an plugin"  (Read 4140 times)

0 Members and 1 Guest are viewing this topic.

MarioR

  • Newt
  • Posts: 64
Problem with "Extension of an plugin"
« on: May 03, 2013, 05:19:46 AM »
Hallo,

I have a finished plugin (dll-A), which works well.
Now I want to write an extension for it (dll B).
The function in the expansion are so special that I do not in
want to integrate the finished plugin (dll A).
I bind the dll to the plugin (dll-A) into the new dll of the plugin (dll B) and inherit the plugin class (class A) in the plugin class (class B).
Is loaded by the netload (dll B).
He throws the following error:

Code: [Select]
   Autodesk.AutoCAD.Runtime.Exception: eDuplicateKey
   bei Autodesk.AutoCAD.Runtime.Interop.Check(Int32 returnValue)
   bei Autodesk.AutoCAD.Runtime.CommandClass.AddCommand(ICommandLineCallable ca, MethodInfo mi)
   bei Autodesk.AutoCAD.ApplicationServices.AutoCADApplicationHolder.Initialize(Assembly assembly)
   bei Autodesk.AutoCAD.ApplicationServices.ExtensionLoader.ProcessAssembly(Assembly assembly)

Exist in both dll's no duplicate commands!
Can it be that the (A dll) is loaded twice?
If so how can I overcome this?

regards Mario

TheMaster

  • Guest
Re: Problem with "Extension of an plugin"
« Reply #1 on: May 03, 2013, 09:53:42 PM »
According to the error, there are multiple CommandMethod attributes with the same command name. I don't see any other way that error could occur.

MarioR

  • Newt
  • Posts: 64
Re: Problem with "Extension of an plugin"
« Reply #2 on: May 07, 2013, 01:32:16 PM »
Hello TT,

I've debugged some times.
It really is that, after a netload dll B
first loads the AutoCAD dll-A and then the dll-B.
This causes the commands from the dll-A load 2 times.

I will change  the dll-B that this not inherit dll-A.

TheMaster

  • Guest
Re: Problem with "Extension of an plugin"
« Reply #3 on: May 07, 2013, 02:55:09 PM »
Hello TT,

I've debugged some times.
It really is that, after a netload dll B
first loads the AutoCAD dll-A and then the dll-B.
This causes the commands from the dll-A load 2 times.

I will change  the dll-B that this not inherit dll-A.

A DLL can't be loaded twice.  Unless there's a bug in AutoCAD managed API that is causing it to process the assembly multiple times, there's no other way the error can happen.


MarioR

  • Newt
  • Posts: 64
Re: Problem with "Extension of an plugin"
« Reply #4 on: May 07, 2013, 09:29:25 PM »
Quote
A DLL can't be loaded twice.  Unless there's a bug in AutoCAD managed API that is causing it to process the assembly multiple times, there's no other way the error can happen.

The dll-A isn't directly loaded twice. AutoCAD loaded all linked Dll's from the dll-B on netload-command.
But the dll-A is also a plugin-dll (has the pluginclass-A), hence loaded autocad the implement commands
from pluginclass-A.
All command of the pluginclass-A from dll-a is inherit in pluginclass-B in dll-B.
Therefor crasht the Commandloader on load plginclass-B.

I have solved the problem by extract all functionality that use the pluginclass-B from pluginclass-A into
new class without Commands. That works fine.

Thanks, over and out

TheMaster

  • Guest
Re: Problem with "Extension of an plugin"
« Reply #5 on: May 22, 2013, 10:52:35 PM »
Quote
A DLL can't be loaded twice.  Unless there's a bug in AutoCAD managed API that is causing it to process the assembly multiple times, there's no other way the error can happen.

The dll-A isn't directly loaded twice. AutoCAD loaded all linked Dll's from the dll-B on netload-command.
But the dll-A is also a plugin-dll (has the pluginclass-A), hence loaded autocad the implement commands
from pluginclass-A.
All command of the pluginclass-A from dll-a is inherit in pluginclass-B in dll-B.
Therefor crasht the Commandloader on load plginclass-B.

I have solved the problem by extract all functionality that use the pluginclass-B from pluginclass-A into
new class without Commands. That works fine.

Thanks, over and out

If you derive a class from another class that has CommandMethods, the runtime sees them on both the derived class and the base class.  That's obviously not a wise thing to do.