I need one clarification related to search path(s) that are looked up for loading the above mentioned "NatvisAddIn.dll". Let me try to explain by extending the above example
To visualize my custom C++ class object(let's say MyCustomeType), I need to call some additional APIs (to compute the display string for MyCustomeType) in the implementation of function(say MyClassFormatter) that is mentioned in "Export" attribute of "DisplayString" XML.
Calling these additional APIs create a library/dll dependency on the above mentioned "NatvisAddIn.dll". If this additional dependency is just one or two library, I can put those library at same location where NatvisAddIn.dll is present. However, in my case the dependency contains a long chain of libraries.
Can some one suggest me some elegant way to resolve the dependency without pulling the complete chain of libraries into %USERPROFILE%\My Documents\Visual Studio 2012\Visualizers folder?
For demonstration of my use case, let's consider the below dependency tree:
NatvisAddIn.dll
a.dll
a1.dll
a2.dll
a3.dll
I copied the a.dll at same location where NatvisAddIn.dll. It's dependent dlls (a1, a2 and a3) are present at location that are added to PATH variable. When I try to visualize MyCustomeType object in visual studio debugger, the natvis diagonostic give the below error in output window
Natvis: C:\Users\myUser\Documents\Visual Studio 2017\Visualizers\mydata.natvis(9,6): Error: Failed to load addin from C:\Users\myuser\Documents\Visual Studio 2017\Visualizers\NatvisAddIn.dll for type MyCustomeType: : The specified module could not be found.
My understanding of above error, the visual studio debugger was not able to resolve dependency of a.dll (a1, a2 and a3) and hence it failed to load NatvisAddIn.dll
When I tried to use a.dll in my testApplication and compute the DisplayString for MyCustomeType, dependency get resolve, a.dll is loaded and I get the expected out string without copying a1.dll, a2.dll and a3.dll. the dependent dll are resolved/picked-up from window PATH variable. But, In case of visual studio debugger, dependent DLL are NOT resolved from PATH variable.
As identified by depends tool, some dlls which are not resolved by debugger are:
api-ms-win-core-errorhandling-l1-1-0.dll
api-ms-win-crt-time-l1-1-0.dll
api-ms-win-crt-heap-l1-1-0.dll
Some of these dll are present visual studio installation, others are present in c:\windows\WinSxS
I've tried my use case on visual studio 2012 and visual studio 2017. I landed up in same issue with both the visual studios.