I have an application that works on most Windows 10 (64-bit) systems, but there are 6 computers that are getting this same BadImageFormatException. The application and libraries are targeting AnyCPU. When attempting to create a COM object from the assembly, I get the exception:
Could not load file or assembly 'InfoConnectCOM.Wrapper64.dll' or one of its dependencies. is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)
Based on the name of the wrapper, it looks like it should be referencing x64 assemblies. There were 30 computers recently imaged the same way, and only 6 have this issue. Additionally, there are a few hundred other Win10 (64-bit) computers that aren't running into this issue.
Private _system As Object
Private Const IC16AssemblyName As String = "InfoConnectCOM.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=13bff1b6907eadcf"
Private Sub CreateIC16SystemObject()
Dim assembly As Reflection.Assembly = Reflection.Assembly.Load(IC16AssemblyName)
Dim type As System.Type = assembly.GetType("Accmgr.AccmgrSystemWrapper")
_system = Activator.CreateInstance(type)
End Sub
The assembly is dynamically loaded since I need the code to work with different version of the software on different platforms.
Stacktrace System.Reflection.TargetInvocationException
System.RuntimeTypeHandle.CreateInstance(type As RuntimeType, publicOnly As Boolean, noCheck As Boolean, canBeCached As Boolean&, ctor As RuntimeMethodHandleInternal&, bNeedSecurityCheck As Boolean&)
QCC.exe: N 00000
System.RuntimeType.CreateInstanceSlow(publicOnly As Boolean, skipCheckThis As Boolean, fillCache As Boolean, stackMark As StackCrawlMark&)
QCC.exe: N 00142
System.Activator.CreateInstance(type As Type, nonPublic As Boolean)
QCC.exe: N 00105
System.Activator.CreateInstance(type As Type)
QCC.exe: N 00012
IAT.AccMgr.Session.CreateIC16SystemObject()
QCC.exe: N 00060
IAT.AccMgr.Session.CreateSystemObject()
QCC.exe: N 00029
IAT.AccMgr.Session..ctor()
QCC.exe: N 00163
Stacktrace BadImageFormatException
System.Reflection.RuntimeAssembly._nLoad(fileName As AssemblyName, codeBase As String, assemblySecurity As Evidence, locationHint As RuntimeAssembly, stackMark As StackCrawlMark&, pPrivHostBinder As IntPtr, throwOnFileNotFound As Boolean, forIntrospection As Boolean, suppressSecurityChecks As Boolean)
QCC.exe: N 00000
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(assemblyRef As AssemblyName, assemblySecurity As Evidence, reqAssembly As RuntimeAssembly, stackMark As StackCrawlMark&, pPrivHostBinder As IntPtr, throwOnFileNotFound As Boolean, forIntrospection As Boolean, suppressSecurityChecks As Boolean)
QCC.exe: N 00457
System.Reflection.RuntimeAssembly.InternalLoadFrom(assemblyFile As String, securityEvidence As Evidence, hashValue As Byte[], hashAlgorithm As AssemblyHashAlgorithm, forIntrospection As Boolean, suppressSecurityChecks As Boolean, stackMark As StackCrawlMark&)
QCC.exe: N 00182
System.Reflection.Assembly.LoadFrom(assemblyFile As String, securityEvidence As Evidence)
QCC.exe: N 00056
System.Activator.CreateInstanceFromInternal(assemblyFile As String, typeName As String, ignoreCase As Boolean, bindingAttr As BindingFlags, binder As Binder, args As Object[], culture As CultureInfo, activationAttributes As Object[], securityInfo As Evidence)
QCC.exe: N 00029
Accmgr.AccmgrSystemWrapper.CreateAccmgrSystemWrapper(installDir As String)
QCC.exe: N 00086
Accmgr.AccmgrSystemWrapper..ctor()
QCC.exe: N 00045
We've tried uninstalling and reinstalling the InfoConnect software. If I change my code and libraries to target x86, then it runs. But, I'd like to avoid having to recompile all the software to target x86.
Any ideas on how to continue troubleshooting this or why only a small number of computers would be affected?
Thanks
Turns out the only C Redistributable Library on the machines was the 32-bit version. The COM Wrapper is in C, so when it attempted to load the mvscr120.dll the wrong version was being pulled. Repairing has resolved the issue.
User contributions licensed under CC BY-SA 3.0