title: Unable to load dll file - exception 0x8007007E
body: <p>I'm working with National Instruments Measurement Studio in C#, and I've come across a bit of a problem in deploying my application to a particular computer (running Windows 7). I've tried asking on the National Instruments forums, but haven't got any solutions yet - could anyone here give me some tips?</p>
  
  <p>Essentially, I have deployed this application several times on a number of computers, but in this particular case I receive an error when running the program -</p>
  
  <blockquote>
    <p>"System.DllNotFoundException: Unable to load DLL 'nianlys.dll': The specified module could not be found. (Exception from HRESULT: 0x80070007E)</p>
  </blockquote>
  
  <ul>
  <li><p>I have ensured that nianlys.dll is present in C:\Program Files
  (x86)\National Instruments\Shared\Analysis.</p></li>
  <li><p>I have ensured that libiomp5md.dll and LV110000_BLASLAPACK.dll, the files from mkl.msm (nianlys.dll has a dependency on mkl.msm), are present. nianlys.dll also has a dependency on nimetautils.msm, but I'm not sure which dlls are included in this.</p></li>
  <li><p>I have ensured the program is installed by running the setup.exe as an administrator (as opposed to running the .msi that is generated, see <a href="http://forums.ni.com/t5/Measurement-Studio-for-NET/unable-to-load-dll-nianlys-dll/m-p/596323/highlight/true#M5940" rel="nofollow noreferrer">here</a>).</p></li>
  <li><p>I have ensured the computer in question is up to date with updates to the .net framework via windows update.</p></li>
  <li><p>I have tried reinstalling the program several times, sometimes with a freshly-recompiled installer.</p></li>
  <li><p>I have tried adding in the 64 bit nianlys.msm into the setup project manually - this throws an error because the TargetPlatform property of the setup project is set to x86. The 32 bit version is, of course, already present in the detected dependencies.</p></li>
  <li><p>Interestingly, taking a copy of nianlys.dll from C:\Program Files (x86)\National Instruments\Shared\Analysis and inserting it into the directory the program is installed in throws up a different error - in this case, the error is:</p>
  
  <blockquote>
    <p>"An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)"</p>
  </blockquote></li>
  <li><p>Taking a copy of the 64 bit version of nianlys.dll from another computer (default location C:\Program Files\National Instruments\Shared\Analysis) and inserting it into the directory the program is installed in throws up a third type of error - "System.DllNotFoundException: Unable to load DLL 'nianlys.dll': A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)". It should be noted that this .dll was present before installing the program on the machines that the program works on, but is <em>not</em> present on the target computer that is throwing up problems.</p></li>
  <li><p>Taking the same 64 bit nianlys.dll and inserting it into the location it was found on on another computer, C:\Program Files\National Instruments\Shared\Analysis, does not solve the original error.</p></li>
  <li><p>Even more interestingly, I have tried to reproduce the error on a computer on which the program works - removing the x64 version of nianlys.dll throws up the original HRESULT: 0x80070007E error, whereas removing the x86 version causes a windows installer to appear when running the program.</p></li>
  <li><p>On a computer upon which the program works with no problems, the windows task manager does not seem to indicate that the program is 32 bit (with the *32 suffix on the program name), despite the target platform being set to x86. It seems from all this that there is some issue with the nianlys.dll being used in both its x64 and x86 versions, despite the target platform only being x86.</p></li>
  </ul>
  
  <p>I'm running out of ideas about what kind of thing I could try to solve this problem.</p>