- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
SETUP:
I am using Visual Studio 2017 to create an add-in for Inventor with C#.
For debugging purposes, my project is set to start Inventor.exe as an external program.
Inside my Build Events property, I have the following post-build event command line:
call "%VS140COMNTOOLS%vsvars32" mt.exe -manifest "$(ProjectDir)ProjectName.X.manifest" -outputresource:"$(TargetPath)";#2 XCopy "$(TargetPath)" "%AppData%\Autodesk\ApplicationPlugins\$(TargetName)\" /Y /R XCopy "$(ProjectDir)Autodesk.ProjectName.Inventor.addin" "%AppData%\Autodesk\ApplicationPlugins\$(TargetName)\" /Y /R
I found this code in a forum and admittedly do not have my head wrapped around how it works, but so far it has been successfully copying my project's *.dll and *.addin files to the appropriate addin folder for Inventor to run my add-in while debugging.
PROBLEM:
My project interacts with a web api that I have built in a separate project. Things were going smoothly until I attempted to deserialize a json object using Newtonsoft.Json. I added a reference to Newtonsoft.Json using the NuGet Package Manager.
The project builds successfully without errors; however, when I run the debugger, I get the following error:
System.IO.FileNotFoundException: 'Could not load file or assembly
'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral,
PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The
system cannot find the file specified.'
I have tried the suggested fixes for this problem that I find online. However, none of them work.
I suspect the issue has to do with the location of Newtonsoft.Json.dll being different than the relative path for which my copied project *.dll or *.addin is looking. This would explain why my project builds successfully only to fail at run-time.
Is there something different I should be doing with my post-build event? Is there some other change I could make to my project to keep NuGet packages references working? Am I way off base on what my problem even is? I am clueless on this problem, and it is preventing me from completing my project. If anybody has insight, I would be extremely grateful.
Solved! Go to Solution.