Vb.net .NET 4.0 WinForm-无法加载文件或程序集或其依赖项之一。不是有效的Win32应用程序

Vb.net .NET 4.0 WinForm-无法加载文件或程序集或其依赖项之一。不是有效的Win32应用程序,vb.net,winforms,com,.net-4.0,badimageformatexception,Vb.net,Winforms,Com,.net 4.0,Badimageformatexception,我有一个可以在大多数Windows 10(64位)系统上运行的应用程序,但有6台计算机出现了同样的BadImageFormatException。应用程序和库的目标是任何CPU。尝试从程序集创建COM对象时,出现异常: 无法加载文件或程序集“InfoConnectCOM.Wrapper64.dll”或一个 它的依赖性。不是有效的Win32应用程序。(不适用于 HRESULT:0x800700C1) 根据包装器的名称,它看起来应该引用x64程序集。最近有30台计算机以同样的方式成像,只有6台出现这

我有一个可以在大多数Windows 10(64位)系统上运行的应用程序,但有6台计算机出现了同样的BadImageFormatException。应用程序和库的目标是任何CPU。尝试从程序集创建COM对象时,出现异常:

无法加载文件或程序集“InfoConnectCOM.Wrapper64.dll”或一个 它的依赖性。不是有效的Win32应用程序。(不适用于 HRESULT:0x800700C1)

根据包装器的名称,它看起来应该引用x64程序集。最近有30台计算机以同样的方式成像,只有6台出现这种问题。此外,还有数百台其他Win10(64位)计算机没有遇到此问题

    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
程序集是动态加载的,因为我需要代码在不同平台上使用不同版本的软件


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

我们已尝试卸载并重新安装InfoConnect软件。如果我将代码和库更改为目标x86,那么它将运行。但是,我希望避免必须重新编译所有软件以实现x86

关于如何继续排除故障,或者为什么只有少数计算机会受到影响,有什么想法吗


谢谢你,机器上唯一的C可再发行库是32位版本。COM包装器是C语言的,因此当它试图加载mvscr120.dll时,拉取了错误的版本。修理已经解决了这个问题