Category Archives: API

“-529697949 (0xe06d7363) Microsoft C++ Exception” with Revit 2015+ API

ERROR: “The program Revit.exe has exited with code -529697949 (0xe06d7363) Microsoft C++ Exception.”

I guess while developing with Revit 2015+ API, you hit this error when you are trying to start Revit in VS to debug? You may want to go to VS – Tools – Options – Debugging, simply check “Use Managed Compatibility Mode”. And try again. Good luck!

4-21-2014 3-28-30 PM

4-21-2014 4-58-58 PM


This is not yet another getting started tutorial on Revit API, but rather a concise checklist and minimum development environment that one can test and verify the system is working before diving into more complex code.

0. the prerequisites:

Make sure Revit 2015/2016 and Visual Studio 2012/2013 is installed. Revit 2015 will not work with older Visual Studios.

1. the project:

Create a new “Class Library” project in “Visual C#” with “.NET Framework 4.5”.

2. the references:

Add RevitAPI.dll, RevitAPIUI.dll and System.Windows.Forms as project references.

Change the “Copy Local” property of RevitAPI.dll and RevitAPIUI.dll to false.

3. the class:

Inherit the Autodesk.Revit.UI.IExternalCommand interface.

Add the following class attribute code before the class declaration.


4. the method:

Implement the Execute method of the inherited interface.

public Autodesk.Revit.UI.Result Execute(
    Autodesk.Revit.UI.ExternalCommandData commandData,
    ref string message,
    Autodesk.Revit.DB.ElementSet elements)
    System.Windows.Forms.MessageBox.Show("Hello World");
    return Autodesk.Revit.UI.Result.Succeeded;

5. the assembly:

Press F6 and VS should report “Build succeeded”.

Note the output path of the dll file shown in the Output window.

6. the GUID:

Create a unique ID for your command.

7. the .addin file

Create an empty text file in: C:\Users\yourUserName\AppData\Roaming\Autodesk\Revit\Addins\201X

(or C:\ProgramData\Autodesk\Revit\Addins\201X).

Change the file name to anyNameWillWork.addin.

Open the file and copy or type the following code:

<?xml version="1.0" encoding="utf-8"?>
    <AddIn Type="Command">

8. DONE!

Now start Revit and you should see an “Add-Ins” tab at the end of Revit tabs, in which there is an “External Tools” button with the newly created External Command.

9. (optional) the debugging:

Point the “Start external program” to the installed revit.exe.

Go to Tools – Options – Debugging, check “Use Managed Compatibility Mode”.

Set a break point in your code.

Press F5 in VS and Revit should be started.

Activate your plugin and you break point should be hit.

~~~~~~~~~~END of original post~~~~~~~~~~

~~~~~~~~~~Update 2015.5.15~~~~~~~~~~


A GitHub repository is created, with the complete Test project for Revit 2016 API. The only thing you need to do is edit the Assembly line in the .addin file, and copy the file to your Revit Addins folder. You are welcome to download the code, and let me know if there are any questions and problems. Enjoy!


As mentioned at the beginning of this post, the content in this post is as concise as possible. If you want more information, here is a tutorial from Autodesk Revit API documentation that contains more details. You may also find the other parts of the documentation to be useful when you try to dig dipper.

How to Debug/Run Navisworks 2013 API Programs

Of course you can just type in code, click build, go to Windows Explorer, copy your dll files to Plugins folder, start Navisworks and click the buttons on the Add-in tab. But what’s fun with that? Besides, that will not give you useful real-time info for debugging. Here in this blog I present you some simple configurations that can make your API life a little bit easier.

Use Post-build Event

Using post-build event to copy the generated dll file (and pdb file for debugging) to the destination folder in Plugins.

1. Right-click the project, choose Properties.

2. Click the Build Events tab on the left, copy the following to the “Post-build event command line”:

xcopy /Y “$(TargetDir)*.*” “C:\Program Files\Autodesk\Navisworks Manage 2013\Plugins\$(TargetName)\”

The “xcopy” is a Windows command for copying stuff. The “/Y” is a switch that tells the system to overwrite anything in the destination folder without letting the user confirm.

The $(Xyz) are macros that will be replaced by actually values. For example, on my machine it will be replaced as “xcopy /Y “D:\zhangle\BIM\Navisworks\API\myVsProjects\LeZhangPlugin\LeZhangPlugin\bin\Debug\*.*” “C:\Program Files\Autodesk\Navisworks Manage 2013\Plugins\LeZhangPlugin\””. Using the macros are good for code portability and ease to read and understand. If your Navisworks is not installed at the default folder, you need to adjust the destination folder accordingly. If you want to know all the macros, you may want to click the “Edit Post-build …” button, and click the “Macros” button.

Configure Start Action

If you just click the “Start” button in VS just like you are doing for any stand-alone application, VS will show you the following error message. Indeed, what we have created is a “Class Library” project, which generates a dll file. We need somehow trigger Navisworks first and run our program in it.


1. Right-click your project name in the Solution Explorer, and click Properties, which is at the bottom of the pop-up menu.

2. Click Debug tab on the left; in Start Action group, choose “Start external program”. Click the browse button to go to Navisworks installation folder, and choose “Roamer.exe”. (I have no idea about the name, but trust me.) Save and close the project properties page.

3. In the code you want to run and debug, find an interesting statement and click the left side border of the code window as shown below. A red dot should be added as a “break point”, which means when running, the program will stop BEFORE running this statement to give you a chance to look into the status of the program.


4. Click the Start button in VS again. Navisworks should start automatically.

5. Do something that will trigger your break point code. You will notice that your program will stop at the statement, while you can check the program status and use the different debug tools.


Keep these in mind if a strange bug appears

Check which .NET framework you are using. Right-click your project – Properties. Make sure the “Target framework” is selected as .NET Framework 4. Since VS2012 uses .NET 4.5 as the default framework, some strange bugs may be as a result of the compatibility between different .NET framework versions. In one of my VS2012 project using Autodesk.Navisworks.Automation.dll, the assembly can be added into the reference without errors, but when running it throws “FileNotFoundException” on the Automation file. Changing the framework back to 4 then works fines.

NOTE: This is a re-post due to broken links on website transfer. The original link to this page is:​sworks-2013-api-programs/