title: HDF5.dll version conflict between Matlab MCR v9.1 and my application
body: <p>MyApp is a C# .NET v4.5.2 WPF app. MyAssembly is a Matlab .NET assembly I created containing MyClass. MyAssembly requires MCR v9.1. MyApp performs various tasks; when one requires Matlab and it tries to instantiate MyClass then a popup window displays:</p>
  
  <blockquote>
    <p>The procedure entry point H5Rdereference could not be located in dynamic link library C:\Program Files\MATLAB\MATLAB Runtime\v91\bin\win64\libmat.dll.</p>
  </blockquote>
  
  <p>MyApp contains a version of hdf5.dll (obtained from Nuget package HDF.PInvoke v1.10.1), and I discovered that MCR 9.1 also contains a (different) version of hdf5.dll in C:\Program Files\MATLAB\MATLAB Runtime\v91\bin\win64. When I replaced MyApp's version of that dll with MCR 9.1's version, MyApp is able to instantiate MyClass, but then MyApp is no longer able to perform its HDF5 tasks; calls to H5.open() throw:</p>
  
  <blockquote>
    <p>Unable to load DLL 'hdf5.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)'</p>
  </blockquote>
  
  <p>MyClass doesn't require HDF5, so why is the MCR loading its copy of that DLL?
  How do I get around this conflict?</p>
  
  <p>Update 1: I moved all of MyApp's non-Matlab-related use of HDF5 into a separate app domain, but the problem persists. It is as if HDF5.dll is getting loaded into the primary app domain even though the code that loads it is executing in a separate app domain.</p>