Navisworks API - Unhandled Exception Error

Navisworks API - Unhandled Exception Error

Anonymous
Not applicable
3,972 Views
2 Replies
Message 1 of 3

Navisworks API - Unhandled Exception Error

Anonymous
Not applicable

I have a console exe that runs from a batch file to generate NWd files from a project list. I usually have it running from a scheduled task from a Windows 4 x64 pc. Although everything was working fine, when I updated some code it quit running from the task. I can double click and it will run fine, but it will not seem to run from a schedule task. I can also run it from with VS 2015 and there does not seem to have any issues or errors. This is the error I get from the Windows log:

 

 

Application: XXXX.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: Autodesk.Navisworks.Api.Automation.AutomationException at Autodesk.Navisworks.Api.Automation.NavisworksApplication.Init(Boolean) at XXXX.Program.Main(System.String[])

 

 

I am still trying to see what broke when I really didn't do much.

Thanks, Jgarza

0 Likes
Accepted solutions (2)
3,973 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Accepted solution

You try the "resolver" library


using Autodesk.Navisworks.Api.Resolver;

 

static void Main()
{
String runtimeName = Resolver.TryBindToRuntime(RuntimeNames.Any);
if (String.IsNullOrEmpty(runtimeName))
{
throw new Exception("Failed to bind to Navisworks runtime");
}
XMain();
}

 

XMain() is the existing Main function.

0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution

After i fix this issue i now get this error with a windows form. I do have it catching to display a messagebox....

 

Error...

 

NWD Issue.PNG

 

 

catch (Autodesk.Navisworks.Api.Automation.AutomationExcption e)
{
//An error occurred, display it to the user
System.Windows.Forms.MessageBox.Show("Error: " + e.Message);

}
catch (Autodesk.Navisworks.Api.Automation.AutomationDocumentFileException e)
{
//An error occurred, display it to the user
System.Windows.Forms.MessageBox.Show("Error: " + e.Message);

}
finally
{
if (automationApplication != null)
{
automationApplication.Dispose();
automationApplication = null;
}

0 Likes