DotNet Console application crashes with a message "FileNotFoundException". Though the dll is present and getting loaded

0

I have a Simple console application which uses a third party dll(32bit)(which is dependent on two more dlls, copied to the same path) and dotnet framework 4.5. This application works in local windows 7 machine. But the same when run in a windows server 2012 R2 crashes with the following message.

System.IO.FileNotFoundException: Could not load file or assembly 'dcasdk.dll' or one of its dependencies. The specified module could not be found.
File name: 'dcasdk.dll'

From Event Viewer :

Faulting application name: ConsoleApplication2.exe, version: 1.0.0.0, time stamp: 0x590c51de
Faulting module name: KERNELBASE.dll, version: 6.3.9600.18340, time stamp: 0x5736541b
Exception code: 0xe0434352
Fault offset: 0x00014878
Faulting process id: 0x9a4
Faulting application start time: 0x01d2c5898c929ee7
Faulting application path: C:\Debug\ConsoleApplication2.exe
Faulting module path: C:\Windows\SYSTEM32\KERNELBASE.dll
Report Id: ca4bbc88-317c-11e7-818e-0ac916d6c5ab
Faulting package full name: 
Faulting package-relative application ID: 

The error message logging logs following message, though all three dlls are in the same place.

System.IO.FileNotFoundException: Could not load file or assembly 'dcasdk.dll' or one of its dependencies. The specified module could not be found.
File name: 'dcasdk.dll'

I tried compiling the application with x86 which dint help.

Any help regarding how to get to the root cause\what makes the dcasdk dll load fail.. will help.


Fusion log

Fusion log says the load was successful. There is no error in fusion log related any other dll, though the application crashes.

=== Pre-bind state information ===
LOG: DisplayName = dcasdk, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Debug/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = ConsoleApplication2.exe
Calling assembly : ConsoleApplication2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Debug\ConsoleApplication2.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Debug/dcasdk.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\Debug\dcasdk.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: dcasdk, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null
LOG: Binding succeeds. Returns assembly from C:\Debug\dcasdk.dll.
LOG: Assembly is loaded in default load context.

Dependency walker shows these dlls as missing.

API-MS-WIN-CORE-WINRT-ERROR-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ROBUFFER-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL
DCOMP.DLL
IESHIMS.DLL
c#
.net
windows
console-application
.net-4.5
asked on Stack Overflow May 5, 2017 by SSQs • edited May 10, 2017 by SSQs

2 Answers

1

Installing MIcrosoft Visual C++ redistributable package(x86) resolved this issue. Dependency walker was misleading. I was able to get to the root cause using Process Monitor tool.

Thanks.

answered on Stack Overflow May 18, 2017 by SSQs
0

I don't have enough rep to post comments, but this is a possible duplicate of BadImageFormatException Could not load file or assembly or one of its dependencies. An attempt was made to load a program with an incorrect format

Was your platform target AnyCPU prior to targeting only x86? Also, the dcasdk.dll are you sure that it also targets AnyCPU and isn't targeted to a specific platform?

answered on Stack Overflow May 5, 2017 by Phil Thomas • edited May 23, 2017 by Community

User contributions licensed under CC BY-SA 3.0