Search code examples
c#visual-studiodependenciesautodesk-navisworks

Forced to manually delete DLL file on each build


I'm building a DLL as part of a plugin for software called Navisworks. When I try to build the DLL I get this error:

Error       Cannot register assembly "C:\Program Files\Autodesk\Navisworks Manage 2021\Plugins\Zoney2021\Zoney2021.dll". Could not load file or assembly 'Autodesk.Navisworks.Api, Version=18.0.1347.51, Culture=neutral, PublicKeyToken=d85e58fa5af9b484' or one of its dependencies. The system cannot find the file specified

I've researched this error plenty and found no obvious solution to it. The referenced assembly is in the right directory and has "copy local" and "specific version" set to false. I've used dependency walker and there are no subdependencies. If I manually delete the Zoney2021.dll the program will run and load the build DLL properly. This shouldn't be a permissions issue since I always run Visual Studio as admin. If there's no easy solution, can I have a script that autodeletes the DLL on each build? Thanks


Solution

  • If you want to delete the file automatically before each build, open your startup project's properties and go to the Build Events tab. There, you can enter a command to delete it.

    Something like:

    cd "C:\Program Files\Autodesk\Navisworks Manage 2021\Plugins\Zoney2021\"
    del Zoney2021.dll