简体   繁体   English

无法在 DLL 的类中加载依赖项 system.drawing.common

[英]Cannot load dependency system.drawing.common in a class in a DLL

I'm copying my program to a Virtual Machine to see what software I need and which settings I need to have enabled (or disabled).我正在将我的程序复制到虚拟机以查看我需要什么软件以及我需要启用(或禁用)哪些设置。 My program is running fine on my work laptop and on my own laptop (older version), but on the VM the program throws an error during run time.我的程序在我的工作笔记本电脑和我自己的笔记本电脑(旧版本)上运行良好,但在 VM 上,程序在运行时抛出错误。

My program is made out of one executable and many DLLs, both the Executable and the DLLs are able to start just fine including using the dependency system.drawing.common .我的程序由一个可执行文件和许多 DLL 组成,可执行文件和 DLL 都能够很好地启动,包括使用依赖项system.drawing.common But one of the classes in one of the DLLs gives an error that the dependency system.drawing.common could not be loaded.但是其中一个 DLL 中的一个类给出了无法加载依赖项system.drawing.common的错误。 Rebuilding the DLL in question doesn't give a warning that something is wrong.重建有问题的 DLL 不会发出错误警告。 See image below for the error I see.请参阅下图了解我看到的错误。

[ERROR][12/18/2019 11:04:02 AM][Thread 0006]> [akka://ModulairVisionFramework/user/AcquireImageActor] Could not load file ? [错误][12/18/2019 11:04:02 AM][Thread 0006]> [akka://ModulairVisionFramework/user/AcquireImageActor] 无法加载文件? or assembly 'System.Drawing.Common, Version=4.0.2.0, Culture=neutral, >PublicKeyToken=cc7b13ffcd2ddd51'.或程序集“System.Drawing.Common,Version=4.0.2.0,Culture=neutral,>PublicKeyToken=cc7b13ffcd2ddd51”。 The system cannot find the file specified.该系统找不到指定的文件。 Cause: System.IO.FileNotFoundException: Could not load file or assembly >'System.Drawing.Common, Version=4.0.2.0, Culture=neutral, >PublicKeyToken=cc7b13ffcd2ddd51'.原因:System.IO.FileNotFoundException:无法加载文件或程序集 >'System.Drawing.Common,Version=4.0.2.0,Culture=neutral,>PublicKeyToken=cc7b13ffcd2ddd51'。 The system cannot find the file specified.该系统找不到指定的文件。 File name: 'System.Drawing.Common, Version=4.0.2.0, Culture=neutral, >PublicKeyToken=cc7b13ffcd2ddd51' at CameraSystem.Actors.AcquireImageActor.<.ctor>b__2_0(AcquireImage resp) at lambda_method(Closure , Object , Action 1 ) at Akka.Tools.MatchHandler.PartialHandlerArgumentsCapture 2.Handle(T >value) at Akka.Actor.ReceiveActor.ExecutePartialMessageHandler(Object message, >PartialAction`1 partialAction) at Akka.Actor.ReceiveActor.OnReceive(Object message) at Akka.Actor.UntypedActor.Receive(Object message) at Akka.Actor.ActorBase.AroundReceive(Receive receive, Object message) at Akka.Actor.ActorCell.ReceiveMessage(Object message) at Akka.Actor.ActorCell.Invoke(Envelope envelope)文件名: 'System.Drawing.Common,版本= 4.0.2.0,文化=中性>公钥= cc7b13ffcd2ddd51'在CameraSystem.Actors.AcquireImageActor <构造函数> b__2_0(AcquireImage RESP)在lambda_method(封闭,对象,动作。 1 ) at Akka.Tools.MatchHandler.PartialHandlerArgumentsCapture 2.Handle(T >value) at Akka.Actor.ReceiveActor.ExecutePartialMessageHandler(Object message, >PartialAction`1 partialAction) at Akka.Actor.ReceiveActor.OnReceive(Object message) at Akka。 Actor.UntypedActor.Receive(Object message) at Akka.Actor.ActorBase.AroundReceive(Receive receive, Object message) at Akka.Actor.ActorCell.ReceiveMessage(Object message) at Akka.Actor.ActorCell.Invoke(信封信封)

What can the cause be that the main executable and the interface of the DLL are both using system.drawing.common fine, but a class in the DLL in question cannot use the dependency?可能是什么原因导致主可执行文件和 DLL 的接口都使用system.drawing.common很好,但是有问题的 DLL 中的一个类不能使用依赖项? And how can this issue be resolved?如何解决这个问题? I have not faced this issue on my work laptop so far or on another computer (older version of my application but still uses system.drawing.common ).到目前为止,我还没有在我的工作笔记本电脑或另一台计算机上遇到过这个问题(我的应用程序的旧版本,但仍然使用system.drawing.common )。

EDIT In both the executable project as in the DLL in question I'm using the NuGet package manager for system.drawing.common .编辑在有问题的 DLL 中的两个可执行项目中,我都将 NuGet 包管理器用于system.drawing.common How the package is included:包是如何包含的:

<PackageReference Include="system.drawing.common" Version="4.6.0" />

I hit this same problem a week or so ago.大约一周前我遇到了同样的问题。 If this is a .NET core assembly, the way you reference it makes a big difference.如果这是一个 .NET 核心程序集,您引用它的方式会产生很大的不同。 Instead of referencing the .NET lib directly (right click -> add reference), use a package reference in the project file:不要直接引用 .NET 库(右键单击 -> 添加引用),而是在项目文件中使用包引用:

<PackageReference Include="System.Drawing.Common" Version="4.6.0" />

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 AWS Lambda 上使用 System.Drawing.Common NuGet 包时无法加载 DLL“libdl” - Unable to load DLL 'libdl' when using System.Drawing.Common NuGet package on AWS Lambda System.drawing.common 'gdip' 的类型初始值设定项抛出异常 - System.drawing.common the type initializer for 'gdip' threw an exception System.Drawing.Common DrawString 无法在 Linux 中正确呈现文本 - System.Drawing.Common DrawString not rendering text properly in Linux 为什么无法删除System.Drawing并替换为NuGet包System.Drawing.Common - Why unable to remove System.Drawing and replace with NuGet package System.Drawing.Common .NET Core System.Drawing.Common PrintDocument在Linux上不起作用 - .NET Core System.Drawing.Common PrintDocument doesn't work on Linux 如何在使用“.NETFramework,Version=v4.5.2”的项目中安装 System.Drawing.Common? - How do I install System.Drawing.Common in a project that uses '.NETFramework,Version=v4.5.2'? 在 Mac OS X 上使用 System.Drawing.Common 将 BMP 转换为 TIFF - Convert BMP to TIFF using System.Drawing.Common on Mac OS X Xamarin.iOS无法从引用的System.Drawing.Common中识别“位图”类型 - Xamarin.iOS does not recognize the 'Bitmap' type from the referenced System.Drawing.Common .NET System.Drawing.Common 4.5.1 的 NuGet 包包含不正确的程序集版本 - NuGet package for .NET System.Drawing.Common 4.5.1 contains incorrect version of assemblies 错误 NU1100:无法为“net6.0”解析“HtmlAgilityPack (&gt;= 1.11.45)”和“System.Drawing.Common (&gt;= 6.0.0)” - error NU1100: Unable to resolve 'HtmlAgilityPack (>= 1.11.45)' and 'System.Drawing.Common (>= 6.0.0)' for 'net6.0'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM