External Commands won't execute

External Commands won't execute

Anonymous
Not applicable
932 Views
5 Replies
Message 1 of 6

External Commands won't execute

Anonymous
Not applicable

I'm having a problem getting revit 2012 to execute my external command.  I did the simple "My First Pluggin" tutorial, and everything worked.  I then switched to VSTA and worked out all my code.  I then went back to VS2010 and updated the tutorial file with my new code.  Everything compiled just fine, but when i run the external command in revit nohing happens. 

 

I went back and recreated the "My First Pluggin" tutorial from scratch, and it won't execute either.  I checked everything repeatedly, but no external commands will work now.

 

I edited the .addin file, and confirmed that it is loading the correct dll.  If i delete the dll, it throws an error on statup indicating that the .addin is pointing to the correct file.

 

I also found that i can delete the .dll file after revit starts, and then run the command without an error being thrown.

 

I'm at a complete loss as to whats going on.  I don't get an error message, just no code execution.  The fact that i can delete the dll after revit boots, and still don't get an error message when i run the application tells me that it's not even loading the dll.

 

Any help would be greatly appreciated.

0 Likes
933 Views
5 Replies
Replies (5)
Message 2 of 6

adam.nagy
Autodesk Support
Autodesk Support

Hi,

 

Revit loads the dll on demand, so only when the user actually executes the command.

 

In order to use VSTA Revit needs to switch to using .NET Framework 2.0 and I guess maybe that's why your AddIn is not working properly.

 

You could either modify the Revit.exe.config so that Revit will use .NET Framework 4.0 or simply call "C:\Program Files\Autodesk\Revit Architecture 2012\Program\RevitVSTAConfig.exe" and select "Restore Revit from VSTA"

 

I hope this helps.

 

Cheers,

Adam Nagy

Autodesk Developer Network



Adam Nagy
Autodesk Platform Services
0 Likes
Message 3 of 6

Anonymous
Not applicable

I actually managed to get it to work by downloading the source for the tutorial and using it.  I've gone over this repeatedly, and i can't find the difference between the 2.   However, i have 2 issues with your reply:

 

1.  Correct me if i'm wrong, but wouln't this then preclude a user from using both?  What if a user purchases an addon dll, but also wants to use VSTA for some of their own small macros?

 

2.  Since it worked when i used the source code, this doesn't seem to be the issue anyhow. I recreated the demo repeatedly, and each time it failed (save for the first time).  Obviously, it would seem that i was making a mistake, but i've been a programmer for more than 20 years, and this is isn't exactly new to me.  The code compiled fine, my tests clearly indicated that the .addin file was correct, and was pointing to the correct dll.  Also the complete absense of an error message makes me doubt it was a .NET error.  I think it would have thrown an error.

 

Since i'm up and running right now, it doesn't much matter to me what the problem was, but i suspect more people will run into this problem in the future.

 

Thanks for your reply.

0 Likes
Message 4 of 6

adam.nagy
Autodesk Support
Autodesk Support

Hi,

 

1) Yes, that is exactly what happens if your AddIn is set to use .NET 4.0

If Revit is set to use .NET 2.0 (so that VSTA will work) then your .NET 4.0 AddIn will not load

 

2) I guess that your new project is using .NET 2.0, 3.0 or 3.5 which are all compatible, and no matter which framework version Revit is loading (depending on the settings in Revit.exe.config) your AddIn will work 

 

I hope this explains.

 

Cheers,

Adam



Adam Nagy
Autodesk Platform Services
0 Likes
Message 5 of 6

Anonymous
Not applicable

Yes, you are correct.  The problem however is that the tutorial clearly states that if you are targeting Revit2012, you should use .NET4.0.  This explains why no matter how many times i tried to recreate the project it always failed.  I was simply following the tutorial as written.

 

I hope someone can update the tutorial so that no one else has to waste a few days trying to figure this out again...

 

0 Likes
Message 6 of 6

adam.nagy
Autodesk Support
Autodesk Support

Good point.

 

I'll ask my colleagues to get the tutorial updated.

 

Thank you.



Adam Nagy
Autodesk Platform Services
0 Likes