3

My team recently upgraded from VS2008 to VS2015. Our project is a combination of C# SDK layers and C++ core libraries that work in mixed mode CLR and direct unmanaged references/pinvoke.

VS2015 compilations for desktop executables work just fine with managed and unmanaged versions across multiple environments. However, when we use the same .NET drivers and C++ libraries in IIS/bin the web server is unable to load any C++ dll that is compiled with CLR. This is within VS2015 and outside of it on both our development and production box. We can set any C++ driver into managed CLR and we see the failed result:

Error Could not load file or assembly 'ConfigAuth.DLL' or one of its dependencies. The specified module could not be found.

The file is clearly found, the PATH variable triple checked. We've run process monitors to find the dll file loading issue and can't seem to find anything that gives a clue as to what is missing. We've had issues in the past with missing redistributable packages and have read that some combinations fail. We've uninstalled and reinstalled these packages, but maybe we are doing it in the wrong sequence/combination?

Development Box / Configuration:

Windows 7, 64bit environment

The following VS C++ Redistributable Packages are installed on the box: 2012,2013,2015 (both x86/64 for each)

SxS merge modules for 2012-2015 are installed

All files compile to Win32/x86 platform

.NET 4.5 is used to compile the ASP.NET WCF Service build as well as all C# managed dlls

.NET 4.0 is the mscorlib used to compile the C++ CLR

IIS 7.5+ 64bit having trouble loading C++ libraries compiled using 2015 toolkit on VS2015.

IIS app pool supports 32 bit assemblies

IIS app pool has all directory and windows access rights set to access the file

PATH variable has been set and tested against other files that load just fine as non CLR

1 Answers1

3

The typical way I debug this is in two phases.

First, I enable fusion logging to see if there are any .Net dependencies missing. Any assemblies that can't be found will have logs written to the specified location. Sometimes what can happen is an app pool will shadow copy assemblies during ASP.Net compilation and not include a dependency. This will help find it.

Second, I run Dependency Walker to get a set of dlls that are depended on by native code, and if I can't tell by just looking at the set, I run Process Monitor and filter on failed DLL loads (Path ends with ".dll" and Result is not "SUCCESS").

Procmon Filter

codekaizen
  • 26,990
  • 7
  • 84
  • 140
  • Thanks for this, we used both tools and found that a lower level driver is failing. We know for a fact that if we use /clr option on any of the drivers we are loading, IIS will fail to load them. If we turn /clr off, they load. I'm pretty sure it is checking for drivers with a /clr setting in the GAC, which could explain our issue. The driver we set to /clr definitely can't compile if we drop it into the Bin folder of the project, and if we drop it into the PATH folders, it still won't load. The Error from Fusion Loggin:Error extracting manifest import from file (hr = 0x80131018). – Kieran Guller Nov 07 '17 at 17:18
  • It's also finding this lower lib from the bin folder. So, I'm a little lost if it is making shadow copies or not. This fails inside VS 2015 IDE Express IIS and IIS stand alone. LOG: Assembly download was successful. Attempting setup of file: C:\Users\kieran\Source\Repos\iTrace\2dmi\WebAPI\bin\BitShuffle.dll LOG: Entering download cache setup phase. ERR: Error extracting manifest import from file (hr = 0x80131018). ERR: Setup failed with hr = 0x80131018. ERR: Failed to complete setup of assembly (hr = 0x80131018). Probing terminated. – Kieran Guller Nov 07 '17 at 17:22
  • Latest Update on this after some more work and investigation of the logs. Many of the log outputs are failures, but there are successes mixed in, so it can be very misleading. I was able to track down that the only driver causing issues is our WriteAMark.dll which I confirmed is a CLR / Managed DLL. I know that IIS has a problem loading these types of drivers and have heard that using the GAC is an option. Is there another way besides a global repo? Can I do something in the web.config to control and load this driver properly into IIS? – Kieran Guller Apr 25 '18 at 19:49