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

2008 .net CommandMethod Error "Binding To Target Method"

2 REPLIES 2
Reply
Message 1 of 3
bncceo
558 Views, 2 Replies

2008 .net CommandMethod Error "Binding To Target Method"

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
2 REPLIES 2
Message 2 of 3
cad4metal
in reply to: bncceo

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
Message 3 of 3
Juergen.Becker
in reply to: cad4metal

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

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