[CONNECT .NET] How does MicroStation find assemblies?

My .NET AddIn uses a third-party assembly Newtonsoft.Json.  If you need to read or write JSON files, it's a very useful addition to your toolkit.

If I build my app as usual, then load and run it in MicroStation, I get an error: 'Cannot load Newtonsoft.Json v12.0.0'.  This had me puzzled, because the build copies the assembly to ..\MicroStation\mdlapps along with the AddIn.  I spent a day trying to work out whether this was a versioning issue (the version no. in Viz Studio is 12.0.3) with no success.  I'm not the only one using Newtonsoft.Json; there's an early version in Microsoft's Windows SDK folder.  Eventually I worked out that MicroStation could not find the assembly in ..\MicroStation\mdlapps.  I copied the assembly to ..\MicroStation, and now it works.

However, I don't want to pollute the ..\MicroStation folder with assemblies that belong to AddIns.  What configuration variable can I use to tell MicroStation to look elsewhere?  MS_ADDINPATH and MS_ADDIN_DEPENDENCYPATH look promising.  In my current installation of CONNECT Update 14.2, they both point to $(MSDIR)mdlsys\filehandler\RealDwg2019\, even though the comment in MicroStation's configuration dialog tells us that MS_ADDIN_DEPENDENCYPATH should not duplicate MS_ADDINPATH.

What's a good solution?

  • Append ..\MicroStation\mdlapps to MS_ADDIN_DEPENDENCYPATH?
  • Create a new folder for my AddIn beneath ..\MicroStation\mdlapps and point MS_ADDIN_DEPENDENCYPATH at that sub-folder?
  • Something else?