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
SSQs
  • 269
  • 2
  • 3
  • 15
  • 1
    Where is `dcasdk.dll`? – rory.ap May 05 '17 at 11:13
  • 1
    I think the key is the "or one of its dependencies" part. Is there a DLL upon which `dcasdk.dll` depends which is not present? – rory.ap May 05 '17 at 11:14
  • The dcasdk.dll is in "C:\Debug" folder. This dll is dependent on two more dlls which are also present in the same folder. The same application works fine in local(Windows7) and gives error in the deployment machine which runs on a windows server 2012 R2. I tried using dependency walker which to find from where it is trying to load the dll. But i could not get any information which is useful from that tool. Fusion log says the dll is getting loaded. – SSQs May 08 '17 at 10:16

2 Answers2

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.

SSQs
  • 269
  • 2
  • 3
  • 15
  • Microsoft Visual C++ 2013 Update 5 Redistributable Package - https://support.microsoft.com/en-gb/help/3179560 – Marius Apr 24 '19 at 15:38
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?

Community
  • 1
  • 1
  • Yes, this issue is related to the one you mentioned. It was working fine in local when i added two more dll's the dcasdk was dependent on and chose Any CPU with prefer32bit ON. This problem is happening in the deployment machine(Windows server 2012 R2), I tried Any CPU(with and without Prefer 32bit), x86 but for no use. – SSQs May 06 '17 at 13:48