2008 .net CommandMethod Error "Binding To Target Method"

2008 .net CommandMethod Error "Binding To Target Method"

Anonymous
Not applicable
853 Views
2 Replies
Message 1 of 3

2008 .net CommandMethod Error "Binding To Target Method"

Anonymous
Not applicable
This is an effort to save someone else this headache.

I have a dotnet app that I have used for 2006 & 2007 and when recompiling for 2008 I noticed a peculiar error. When using one of my commands, AutoCAD now throws a very ambiguous "Error Binding To Target Method" exception. After analyzing my own code, and several hours of trying things that didn't work, I realized that this specific command invoked a function in my app that returned a value, whereas all of the rest of my commands invoke void methods. I do not understand why this would be the case for 2008 and not before, but the fix was easy enough.

Since this function serves two purposes in my app, I cannot ditch the return value. So the solution is to simply wrap the function in a regular method with no return value.

C#:

[CommandMethod("NB")]
public static void NewCommandWrapper() {
NewCommand();
}

public static bool NewCommand() {
// Do Some Acad Stuff
// Return a value
}

I hope this saves someone a little time.

Regards,
RT
0 Likes
854 Views
2 Replies
Replies (2)
Message 2 of 3

cad4metal
Explorer
Explorer
Dear RT

Thanks for your help. I had the same error with visual basic .net. I changed my startup command from function to sub (no return value) and it works!

Error message was (german): "Fehler beim Binden an die Zielmethode"

Regards,
Peter
0 Likes
Message 3 of 3

Anonymous
Not applicable

Hi,

 

just about 3 years later. Here cames the answer.

 

i've got the same error and I think I know the reason why the error apears.

Its depends on the parameter and the return-parameter.

The method that defined in C# must have a parameter as a ResultBuffer. The return-parameter is not so importend.

 

This works:

 

Lisp:

(RenameUnnamedBlocks "1")

 

C#:

[LispFunction("RenameUnnamedBlocks")]
public void LispRenameUnnamedBlocks(ResultBuffer Value)
{
ACADUtility.Block.RenameUnnamedBlocks();//Just a method in C#.
}

 

Regards Jürgen

0 Likes