Home Could not load file or assembly 'EX.DLL' or one of its dependencies in WCF App but not in Console App
Reply: 0

Could not load file or assembly 'EX.DLL' or one of its dependencies in WCF App but not in Console App

Squar3R007
1#
Squar3R007 Published in 2018-01-12 21:36:53Z

I am creating a WCF Application that works with an SDK that I was given. For testing purposes I created a console application to work with the SDK. After I had confirmed that my code worked with the SDK properly, I replicated the functionality with the WCF Application. When I invoke the application with a SOAP client I get the following error thrown as an exception when I invoke code from the SDK.

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

All other endpoints are still fully functional and code paths that avoid the SDK do not fail. Both projects are using .NET 4.7.

My first thought was that it had to do with the copy local or output directory of one of the files. I tried changing copy local to true. This caused the same error to appear in the browser when navigating the localhost page and does prevent the other endpoints from working.

The only DLL I am referencing for this is 'EM.DLL'. They are located in the same file folder so I doubted that the application couldn't find that one. Instead I started looking for something that could be its dependency. There are 76 other DLLs in the SDK folder so trial and error wasn't really an option. Instead I tried to figure out what the dependency could be by using Dependency Walker but I'm not familiar enough with the program to understand what's going on when I open the DLL and the answer is not readily apparent.

Does WCF handle DLL loading differently than a console app? How can I find which DLL is failing to load?

Edit: I've now tried changing the architecture, telling iss to probe the dlls filepath, adding the dlls to the GAC instead and various combinations of adding the dlls to the references with all combinations of copy local all while looking through the Fusion Logs. Some combinations allow me to get the error through the soap call while others fail on startup with seeming random preference. Often times it does find the EX.DLL but it must be one of its dependencies that it can't find and the logs do not tell me what the dependencies are.

Edit 2: Here is the Fusion Log Viewer for those asking. fuslogvw.exe

And here is the output of the EX log when EM's copy local is set to false in the project references. If I set it to true, this log changes to a success where it found the dll the temp files of the program but then it fails on startup with the same error message. This way, the log is only generated when I try to call the specific code in that dll.

*** Assembly Binder Log Entry  (1/15/2018 @ 9:58:23 AM) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Program Files (x86)\IIS Express\iisexpress.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = EX, Version=9.7.2079.1117, Culture=neutral, PublicKeyToken=0ca8877e5830dba7
 (Fully-specified)
LOG: Appbase = file:///C:/Users/username/Source/Repos/solutionpath/ProjectName/
LOG: Initial PrivatePath = C:\Users\username\Source\Repos\solutionpath\ProjectName\bin
LOG: Dynamic Base = C:\Users\username\AppData\Local\Temp\Temporary ASP.NET Files\vs\e167a27b
LOG: Cache Base = C:\Users\username\AppData\Local\Temp\Temporary ASP.NET Files\vs\e167a27b
LOG: AppName = 8d6fbe3b
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\username\Source\Repos\solutionpath\ProjectName\web.config
LOG: Using host configuration file: C:\Users\username\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Users/username/AppData/Local/Temp/Temporary ASP.NET Files/vs/e167a27b/8d6fbe3b/EX.DLL.
LOG: Attempting download of new URL file:///C:/Users/username/AppData/Local/Temp/Temporary ASP.NET Files/vs/e167a27b/8d6fbe3b/EX/EX.DLL.
LOG: Attempting download of new URL file:///C:/Users/username/Source/Repos/solutionpath/ProjectName/bin/EX.DLL.
LOG: Attempting download of new URL file:///C:/Users/username/Source/Repos/solutionpath/ProjectName/bin/EX/EX.DLL.
LOG: Attempting download of new URL file:///C:/Users/username/AppData/Local/Temp/Temporary ASP.NET Files/vs/e167a27b/8d6fbe3b/EX.EXE.
LOG: Attempting download of new URL file:///C:/Users/username/AppData/Local/Temp/Temporary ASP.NET Files/vs/e167a27b/8d6fbe3b/EX/EX.EXE.
LOG: Attempting download of new URL file:///C:/Users/username/Source/Repos/solutionpath/ProjectName/bin/EX.EXE.
LOG: Attempting download of new URL file:///C:/Users/username/Source/Repos/solutionpath/ProjectName/bin/EX/EX.EXE.
LOG: All probing URLs attempted and failed.

*** Assembly Binder Log Entry  (1/15/2018 @ 9:58:23 AM) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Program Files (x86)\IIS Express\iisexpress.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = EX, Version=9.7.2079.1117, Culture=neutral, PublicKeyToken=0ca8877e5830dba7
 (Fully-specified)
LOG: Appbase = file:///C:/Users/username/Source/Repos/solutionpath/ProjectName/
LOG: Initial PrivatePath = C:\Users\username\Source\Repos\solutionpath\ProjectName\bin
LOG: Dynamic Base = C:\Users\username\AppData\Local\Temp\Temporary ASP.NET Files\vs\e167a27b
LOG: Cache Base = C:\Users\username\AppData\Local\Temp\Temporary ASP.NET Files\vs\e167a27b
LOG: AppName = 8d6fbe3b
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\username\Source\Repos\solutionpath\ProjectName\web.config
LOG: Using host configuration file: C:\Users\username\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Users/username/AppData/Local/Temp/Temporary ASP.NET Files/vs/e167a27b/8d6fbe3b/EX.DLL.
LOG: Attempting download of new URL file:///C:/Users/username/AppData/Local/Temp/Temporary ASP.NET Files/vs/e167a27b/8d6fbe3b/EX/EX.DLL.
LOG: Attempting download of new URL file:///C:/Users/username/Source/Repos/solutionpath/ProjectName/bin/EX.DLL.
LOG: Attempting download of new URL file:///C:/Users/username/Source/Repos/solutionpath/ProjectName/bin/EX/EX.DLL.
LOG: Attempting download of new URL file:///C:/Users/username/AppData/Local/Temp/Temporary ASP.NET Files/vs/e167a27b/8d6fbe3b/EX.EXE.
LOG: Attempting download of new URL file:///C:/Users/username/AppData/Local/Temp/Temporary ASP.NET Files/vs/e167a27b/8d6fbe3b/EX/EX.EXE.
LOG: Attempting download of new URL file:///C:/Users/username/Source/Repos/solutionpath/ProjectName/bin/EX.EXE.
LOG: Attempting download of new URL file:///C:/Users/username/Source/Repos/solutionpath/ProjectName/bin/EX/EX.EXE.
LOG: All probing URLs attempted and failed.

*** Assembly Binder Log Entry  (1/15/2018 @ 9:58:23 AM) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Program Files (x86)\IIS Express\iisexpress.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = EX, Version=9.7.2079.1117, Culture=neutral, PublicKeyToken=0ca8877e5830dba7
 (Fully-specified)
LOG: Appbase = file:///C:/Users/username/Source/Repos/solutionpath/ProjectName/
LOG: Initial PrivatePath = C:\Users\username\Source\Repos\solutionpath\ProjectName\bin
LOG: Dynamic Base = C:\Users\username\AppData\Local\Temp\Temporary ASP.NET Files\vs\e167a27b
LOG: Cache Base = C:\Users\username\AppData\Local\Temp\Temporary ASP.NET Files\vs\e167a27b
LOG: AppName = 8d6fbe3b
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\username\Source\Repos\solutionpath\ProjectName\web.config
LOG: Using host configuration file: C:\Users\username\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
ERR: Unrecoverable error occurred during pre-download check (hr = 0x80070002).

*** Assembly Binder Log Entry  (1/15/2018 @ 9:58:23 AM) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Program Files (x86)\IIS Express\iisexpress.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = EX, Version=9.7.2079.1117, Culture=neutral, PublicKeyToken=0ca8877e5830dba7
 (Fully-specified)
LOG: Appbase = file:///C:/Users/username/Source/Repos/solutionpath/ProjectName/
LOG: Initial PrivatePath = C:\Users\username\Source\Repos\solutionpath\ProjectName\bin
LOG: Dynamic Base = C:\Users\username\AppData\Local\Temp\Temporary ASP.NET Files\vs\e167a27b
LOG: Cache Base = C:\Users\username\AppData\Local\Temp\Temporary ASP.NET Files\vs\e167a27b
LOG: AppName = 8d6fbe3b
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\username\Source\Repos\solutionpath\ProjectName\web.config
LOG: Using host configuration file: C:\Users\username\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
ERR: Unrecoverable error occurred during pre-download check (hr = 0x80070002).

One of the strange things about the EM log is that it seems to find it in the GAC. I did not add it to the GAC and if I try to remove it BOTH the WCF application and the Console application encounter exceptions at startup. I thought the reference was supposed to tell it the path to the file.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.325772 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO