0

In our company the Windows was updated from 1809 to 2004. Now, on a few computers our C# program did not work correctly.

AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap(m_sAssemblyPath + "XYZ.DLL", "AAA.XXX.XYZ.ZZZ");

fails.

We sell this program, so management ask me to find the source and solution to the problem. Because the program is needed, every failing instance was reinstalled (repair installation did not work) except one on a laptop used by an external sales man. So I have not continues access to it. Following my finding. Are there any other tools / ideas?

Attached with remote Debugger:

[...]
'XXX.exe' (Win32): Loaded 'C:\Windows\SysWOW64\clbcatq.dll'. Symbols loaded.
'XXX.exe' (Win32): Loaded 'C:\Program Files (x86)\YYY\XYZ.dll'. 
'XXX.exe' (Win32): Loaded 'C:\Program Files (x86)\YYY\XYZ.dll'. 
'XXX.exe' (Win32): Unloaded 'C:\Program Files (x86)\YYY\XYZ.dll'
'XXX.exe' (Win32): Unloaded 'C:\Program Files (x86)\YYY\XYZ.dll'
'XXX.exe' (Win32): Loaded 'C:\Program Files (x86)\YYY\XYZ.dll'. 
'XXX.exe' (Win32): Loaded 'C:\Program Files (x86)\YYY\XYZ.dll'. 
'XXX.exe' (Win32): Unloaded 'C:\Program Files (x86)\YYY\XYZ.dll'
'XXX.exe' (Win32): Loaded 'C:\Windows\SysWOW64\urlmon.dll'. Symbols loaded.
'XXX.exe' (Win32): Loaded 'C:\Windows\SysWOW64\iertutil.dll'. Symbols loaded.
'XXX.exe' (Win32): Loaded 'C:\Windows\SysWOW64\IEAdvpack.dll'. Symbols loaded.
'XXX.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\IEAdvpack.dll'
'XXX.exe' (Win32): Loaded 'C:\Windows\SysWOW64\IEAdvpack.dll'. Symbols loaded.
'XXX.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\IEAdvpack.dll'
'XXX.exe' (Win32): Loaded 'C:\Windows\SysWOW64\IEAdvpack.dll'. Symbols loaded.
'XXX.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\IEAdvpack.dll'
'XXX.exe' (Win32): Loaded 'C:\Windows\SysWOW64\IEAdvpack.dll'. Symbols loaded.
'XXX.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\IEAdvpack.dll'
'XXX.exe' (Win32): Loaded 'C:\Windows\SysWOW64\IEAdvpack.dll'. Symbols loaded.
'XXX.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\IEAdvpack.dll'
Ausnahme ausgelöst bei 0x767F9862 in XXX.exe: Microsoft C++-Ausnahme: HRException bei Speicherort 0x084FDE28.
Ausnahme ausgelöst bei 0x767F9862 in XXX.exe: Microsoft C++-Ausnahme: [rethrow] bei Speicherort 0x00000000.
Ausnahme ausgelöst bei 0x767F9862 in XXX.exe: Microsoft C++-Ausnahme: Exception bei Speicherort 0x084FE19C.

Stack:

mscorlib.dll!System.IO.FileLoadException.FileLoadException(string fileName = "file:///C:\\Program Files (x86)\\YYY\\XYZ.dll", string fusionLog = "", int hResult = 0x8000ffff) Line 149    C#
 [Übergang von Systemeigen zu Verwaltet]    
 [Übergang von Verwaltet zu Systemeigen]    
 mscorlib.dll!System.Reflection.RuntimeAssembly.nLoad(System.Reflection.AssemblyName fileName, string codeBase, System.Security.Policy.Evidence assemblySecurity, System.Reflection.RuntimeAssembly locationHint, ref System.Threading.StackCrawlMark stackMark, System.IntPtr pPrivHostBinder, bool throwOnFileNotFound, bool forIntrospection, bool suppressSecurityChecks) Line 1951    C#
 mscorlib.dll!System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity, System.Reflection.RuntimeAssembly reqAssembly, ref System.Threading.StackCrawlMark stackMark, System.IntPtr pPrivHostBinder, bool throwOnFileNotFound, bool forIntrospection, bool suppressSecurityChecks) Line 1859    C#
 mscorlib.dll!System.Reflection.RuntimeAssembly.InternalLoadFrom(string assemblyFile, System.Security.Policy.Evidence securityEvidence, byte[] hashValue, System.Configuration.Assemblies.AssemblyHashAlgorithm hashAlgorithm, bool forIntrospection, bool suppressSecurityChecks, ref System.Threading.StackCrawlMark stackMark) Line 1709    C#
 mscorlib.dll!System.Reflection.Assembly.LoadFrom(string assemblyFile, System.Security.Policy.Evidence securityEvidence) Line 195    C#
 mscorlib.dll!System.Activator.CreateInstanceFromInternal(string assemblyFile, string typeName = "AAA.XXX.XYZ.ZZZ", bool ignoreCase = false, System.Reflection.BindingFlags bindingAttr = Instance | Public | CreateInstance, System.Reflection.Binder binder = null, object[] args = null, System.Globalization.CultureInfo culture = null, object[] activationAttributes = null, System.Security.Policy.Evidence securityInfo) Line 437    C#
 mscorlib.dll!System.AppDomain.CreateInstanceFrom(string assemblyFile, string typeName) Line 1581    C#
 mscorlib.dll!System.AppDomain.CreateInstanceFromAndUnwrap(string assemblyName, string typeName) Line 4598    C#
 XXX.exe!AAA.XXX.BBB.Initialize(int iNumberOfInstruments = 0x00000002, bool bShowConfigUI = true, int iUserLevel = 0x00000001, bool bUserPermissionValid = true, AAA.XXX.InstrumentInterfaces.EWinGpcKeyFlags winGpcKeyFlags = NumberOfInstruments2 | Viscosity | LightScattering | Copolymer | TwoDGpc | Heparin | ChemicalHeterogenity | WindowsNTEdition | ListLabelReportDesigner | LANInterface | NoDongleRequired | ChromPilotDriver0 | CFR_21_11 | WinGPC8 | ChromPilotDriver1 | ChromPilotDriver2 | ChromPilotDriver3 | ChromPilotDriver4 | ChromPilotDriver5 | ChromPilotDriver6 | ThreeDSpectraModuleLicenseAvailable | MsModuleLicenseAvailable, System.Windows.Forms.NativeWindow nativeWindowWinGPC = {System.Windows.Forms.NativeWindow}) Line 677    C#
 XXX.exe!AAA.XXX.ChromPilot.ReceivedWinGPCCommand_Confirm_GetPermission(int succeeded = 0x00000001) Line 1436    C#
 [Übergang von Systemeigen zu Verwaltet]    
 [Übergang von Verwaltet zu Systemeigen]    
 mscorlib.dll!System.Delegate.DynamicInvokeImpl(object[] args) Line 123    C#
 mscorlib.dll!System.Delegate.DynamicInvoke(object[] args) Line 114    C#
 XXX.exe!AAA.XXX.WorkerThread.WorkItem.Execute() Line 158    C#
 XXX.exe!AAA.XXX.WorkerThread.WorkerProc() Line 425    C#
 mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) Line 74    C#
 mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 980    C#
 mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 928    C#
 mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Line 917    C#
 mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() Line 111    C#
 [Übergang von Systemeigen zu Verwaltet]    
 kernel32.dll!@BaseThreadInitThunk@12()    Unknown
 ntdll.dll!__RtlUserThreadStart()    Unknown
 ntdll.dll!__RtlUserThreadStart@8()    Unknown

0x8000ffff: E_UNEXPECTED

Fusion Log says: Success (sadly I havn't the logs any more).

Sysinternals Process Monitor did not show anything interesting. Last access: mscorelib / HKCR\WOW6432Node\CLSID{0A29FF9E-7F9C-4437-8B11-F424491E3931}

sfc /scannow Did not solve this problem

Windows Logs: Nothing

Edit:

Dependency Walker without any findings

Ralph Erdt
  • 521
  • 6
  • 16
  • Finally, found the problem. During the initialization of the program (far before this!) a (Impersonated) "WNetAddConnection" fails with Access Violation deep in Windows API. Changed the API to Version 3: now it works. I've no clue why this leads to a failing DLL load (after a lot of other DLLs are successfully loaded). – Ralph Erdt Aug 09 '21 at 08:15

0 Answers0