admin管理员组

文章数量:1334825

I have a C# app which uses a C# DLL which is a wrapper around PCL 1.12.1. The two known dependencies are vcredist and the 8 runtime. All the PCL dlls are deployed with the app.

I wanted to test it on a fresh machine. For this I picked a dell laptop and a VM. Both have x64 Win10 Pro and were installed using the same consumer Win10 ISO. Also both are fully up to date with identical versions (version 22H2, OSBuild 19045.5131). Both also have the known depdencies isntalled, I.e., the latest vcredist (14.42.34433) and 8 desktop runtime (8.0.11).

After copying my app to the documents folder of each user on each machine, on the laptop the app runs fine but on the VM the app crashes when attempting to call one of the DLL functions with the following error: Unhandled exception: System.DllNotFoundException: Unable to load DLL (myDll.dll) or one of its depdencies: A dynamic link library (DLL) initialization routine failed. (0x8007045A).

Things I've tried:

  • using dumpbin to confirm the expected dependencies.
  • using depencies; some missing dependencies are listed but these match on both the laptop and VM (all direct dependencies are fine but there are many dlls in the form ext-ms-win-xxx-l1-1-0.dll listed as missing inside some of the dependent DLLs)
  • using depdency-walker: again many missing dependencies are listed but these match on the laptop and VM.
  • using depdency-walkers profiling function but this locks up at roughly the point it calls out to the DLL on the VM (I tried leaving it for hours to see if it ever became responsive again to no avail) and weirdly profiling fails to run on the laptop where my app actually works with error code 0x0000142. In both instances I tried using dependency walker 2.2.6000 and 2.2.10011.
  • using process monitor to monitor access to my DLL; with a filter to include events where path contains myDll.dll. My Dll is accessed a bunch by my app exe and MsMpEng.exe and a bit by csrss.exe on both the laptop and my VM. But also, on my VM it is hammered by WerFault.exe, I guess confirming my app has crashed. The PATH NOT FOUND entries are identical for each.
  • using process monitor to monitor events made by my executable; there is no obvious difference here. There are lots of NAME NOT FOUND entries as it searches for dependencies but these roughly match on both the laptop and VM. Nothing stands out.
  • adding logging to my DLLs in dllmain to log various events. Logging works fine on the laptop but no logging occurs on the VM, suggesting no code within the dll actually runs.

So how can I further diagnose this issue? Are there any other tools or strategies I can try? maybe there are some fundamental differences between VMs and physical installs I'm not considering?

本文标签: cHow can a dll initialisation failure be diagnosed (failing exclusively on VMs)Stack Overflow