C# 程序可以在开发笔记本电脑上运行,但不能在另一台笔记本电脑上运行 [英] C# program can run on development laptop, but cannot on another

查看:20
本文介绍了C# 程序可以在开发笔记本电脑上运行,但不能在另一台笔记本电脑上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在过去的 6 个月里,我一直在为我的实习开发 Windows 应用程序.该程序在其编程的笔记本电脑上正常工作,但我需要在另一台笔记本电脑上设置该程序.我安装了相同的 dotnet 核心版本 (3.0.100) 并在同一目录中启动了 .exe 和所有必需的 DLL(编译时).但是当我这样做时,我得到如下所示的错误.

I have been developing a Windows application for the past 6 months for my internship. This program works as it should do on the laptop where its programmed, but I need to set the program on another laptop. I installed the same dotnet core version (3.0.100) and started the .exe with all the DLLs necessary in the same directory (as it is compiled). But when I do this I get the error shown below.

[ERROR][1/23/2020 7:58:41 PM][Thread 0006][akka://ModulairVisionFramework/user/InterfaceCameraActor] Error while creating actor instance of type CameraSystem.InterfaceCameraActor with 0 args: ()
Cause: [akka://ModulairVisionFramework/user/InterfaceCameraActor#1923472091]: Akka.Actor.ActorInitializationException: Exception during creation
 ---> System.TypeLoadException: Error while creating actor instance of type CameraSystem.InterfaceCameraActor with 0 args: ()
 ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.BadImageFormatException: Could not load file or assembly 'VimbaNET, Version=1.8.0.27270, Culture=neutral, PublicKeyToken=96b729f24f119b9a'. An attempt was made to load a program with an incorrect format.
File name: 'VimbaNET, Version=1.8.0.27270, Culture=neutral, PublicKeyToken=96b729f24f119b9a'
   at CameraSystem.InterfaceCameraActor..ctor()

   --- End of inner exception stack trace ---
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean wrapExceptions, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& hasNoDefaultCtor)
   at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean fillCache)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, Boolean wrapExceptions)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, Object[] args)
   at Akka.Actor.Props.ActivatorProducer.Produce()
   at Akka.Actor.Props.NewActor()
   --- End of inner exception stack trace ---
   at Akka.Actor.Props.NewActor()
   at Akka.Actor.ActorCell.CreateNewActorInstance()
   at Akka.Actor.ActorCell.<>c__DisplayClass109_0.<NewActor>b__0()
   at Akka.Actor.ActorCell.UseThreadContext(Action action)
   at Akka.Actor.ActorCell.NewActor()
   at Akka.Actor.ActorCell.Create(Exception failure)
   --- End of inner exception stack trace ---
   at Akka.Actor.ActorCell.Create(Exception failure)
   at Akka.Actor.ActorCell.SysMsgInvokeAll(EarliestFirstSystemMessageList messages, Int32 currentState)

[INFO][1/23/2020 7:58:44 PM][Thread 0008][akka://ModulairVisionFramework/user/InterfaceCameraActor] Message Initialize from akka://ModulairVisionFramework/user/FrameworkActor to akka://ModulairVisionFramework/user/InterfaceCameraActor was not delivered. 1 dead letters encountered.

这个错误System.BadImageFormatException:无法加载文件或程序集让我觉得我可能使用了错误的VimbaNET DLL,但我100%确定我用的是正确的.如果我确实使用了 VimbaNET 的错误 DLL,那么我会得到与上面相同的错误,但如果我使用正确的 DLL,我也会得到错误.我也尝试在新的笔记本电脑上用相同的 IDE 编译应用程序,但结果是一样的.

This error System.BadImageFormatException: Could not load file or assembly gives me the idea that I may use the wrong DLL of VimbaNET, but I'm 100% sure that I use the right one. If I do use the wrong DLL of VimbaNET then I do get the same error as above, but I also get the error if I use the right DLL. I also tried to compile the application on the new laptop with the same IDE, but the result is the same.

两台笔记本电脑都是 64 位.

Both of the laptops are 64 bit.

有谁知道我如何解决这个问题?

Does anyone know how I can solve this issue?

我的应用程序的 32 位版本给出了同样的错误.

The 32bit version of of my application gives the same error.

我用来编译和运行 64 位程序的设置.

Settings that I use to compile and run the program in 64bit.

我用来编译和运行 32 位程序的设置.

Settings that I use to compile and run the program in 32bit.

问题中涉及的所有 3 个程序集的程序集信息.

assembly Information of all 3 assemblies that are involved in the issue.

VimbaNET 是导致问题的 DLL

VimbaNET is the DLL that causes the issues

CameraSystem 是我自己使用 VimbaNET 的程序集

CameraSystem is my own Assembly that used VimbaNET

ModulairVisionFramework 是使用 CameraSystem 组件的主要应用程序

ModulairVisionFramework is the main application that makes use of the CameraSystem assembly

推荐答案

安装 .NET 3.5 解决了这个问题,因为 Vimba SDK 依赖于 .NET 2(不,不是 .NET Standard 或 Core 2)(阅读 Vimba C#API 文档)..NET 3.5 包括 .NET 2 运行时.

Installing .NET 3.5 solves the problem since Vimba SDK has a dependency to .NET 2 (no, not .NET Standard or Core 2) (read the Vimba C# API documentation). .NET 3.5 includes .NET 2 runtime.

这篇关于C# 程序可以在开发笔记本电脑上运行,但不能在另一台笔记本电脑上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆