System.BadImageFormatException - Autodesk.Navisworks.Automation

System.BadImageFormatException - Autodesk.Navisworks.Automation

senthilkumar_balu
Participant Participant
1,648 Views
2 Replies
Message 1 of 3

System.BadImageFormatException - Autodesk.Navisworks.Automation

senthilkumar_balu
Participant
Participant

Hi All,

 

  I am a newbie, I am trying to create a windows form c # application referencing the (Filemanipulation example) to open and save a dxf file into nwd. I have added reference to Autodesk.Navisworks.Automatio.Api. But when i try to build and debug the application i am getting an error as 

"System.BadImageFormatException: 'Could not load file or assembly 'Autodesk.Navisworks.Automation, Version=17.0.1336.83, Culture=neutral, PublicKeyToken=d85e58fa5af9b484' or one of its dependencies. An attempt was made to load a program with an incorrect format.' "

 

Can you please help me with this.

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

awmcc90VZTT2
Contributor
Contributor
Accepted solution

You're building your project targeting a different architecture than one of your references, Autodesk.Navisworks.Automation. 

 

The Automation module targets 64 bit architecture and I'm assuming your building your project targeting Any CPU or x86. Change your build platform target to x64 and you should be fine. 

 

A note about Winforms: The winforms designer in Visual Studio might have issues or not work at all if you target x64. Maybe move to WPF if this becomes an issue.

Message 3 of 3

senthilkumar_balu
Participant
Participant
Accepted solution

Thank you for your response. It helped. 

Actually i have changed the target framework to .Net Framework 4.7.2 from 4.6 and it worked.

0 Likes