Message 1 of 3
2008 .net CommandMethod Error "Binding To Target Method"
Not applicable
05-11-2007
11:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
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