【问题标题】:Cannot load type from load type 'System.Drawing.Font' from assembly 'System.Drawing, Version=4.0.0.0无法从程序集“System.Drawing,版本=4.0.0.0”的加载类型“System.Drawing.Font”加载类型
【发布时间】:2017-11-14 14:01:58
【问题描述】:

我知道有类似的问题,但我找不到答案,所以我会问一个具体的问题。 我有一个简单的 .net 核心控制台应用程序。 我正在使用 Syncfusion.DocIO.Base 和 Syncfusion.Core 程序集从这样的流中创建 WordDocument:

var word = new WordDocument(rtfStream, FormatType.Rtf);

在这里我收到错误消息: 无法从程序集“System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”中加载类型“System.Drawing.Font”。

你知道我在哪里可以解决这个问题吗?`

【问题讨论】:

  • 嗨,尝试检查天气 System.Drawing 是否在应用程序的输出文件夹中。也许您需要在构建时复制它。看起来 Syncfusion 的依赖项之一无法应对构建。
  • @VladimirShmidt 我在 Dependencies->SDK->System.Drawing 中看到 System.Drawing。如果这不是你的意思,请告诉我你说的输出文件夹是什么意思?谢谢
  • 您是否使用过 nuget 包管理器来拉取所有必需的库。我猜你缺少其他 dll 使用的依赖项。此 dll 已添加到您的参考中?
  • @Prasadtelkikar 我已将 Syncfusion 引用添加到我的程序集中,它们使用 System.Drawing dll。我在 SDK->Microsoft.NETCore.App 中有 System.Drawing.dll。当我从 nuget 中提取库时发生了同样的事情。

标签: c# .net-core syncfusion


【解决方案1】:

System.Drawing.Font 类型在 .NET Core 2.0 中不可用。虽然 .NET Core 有 System.Drawing.dllSystem.Drawing.Primitives.dll,但它们不包含这种类型,正如使用完整 .NET Framework 绘图功能的库所期望的那样。

.NET Core 2.1 计划支持这些功能,请参阅related GitHub issue

【讨论】:

    【解决方案2】:

    您引用了包含 ASP.NET Core 应用程序不支持的“System.Drawing”引用的基础程序集。

    因此,请参考以下程序集/NuGet 包以使用 ASP.NET Core 中的 Essential DocIO 处理 Word 文档。

    Syncfusion.Compression.Portable
    Syncfusion.DocIO.Portable
    Syncfusion.OfficeChart.Portable
    
    1. 您可以从以下位置找到已安装的程序集和 NuGet 包。
      $系统驱动器:\Users\$user.nuget\packages\Syncfusion.DocIO.Portable 例如:C:\Users\username.nuget\packages\Syncfusion.DocIO.Portable
    2. 您可以从以下链接在线找到 ASP.NET Core NuGet 包。 http://nuget.syncfusion.com/package/aspnetcore

    请参阅以下链接以了解有关 ASP.NET Core 迁移更改的更多信息。 https://help.syncfusion.com/aspnet-core/release-notes/migratingtov15.3.0.26?type=all

    请参阅下面的 UG 文档链接以了解更多有关使用 Essential DocIO 配置 ASP.NET Core 的信息。

    https://help.syncfusion.com/aspnet-core/gettingstarted/getting-started-1-1-0 https://help.syncfusion.com/aspnet-core/installation

    https://help.syncfusion.com/aspnet-core/gettingstarted/getting-started-1-1-0#configure-syncfusion-file-format-components-in-aspnet-core-application

    https://help.syncfusion.com/aspnet-core/docio/overview

    如有其他问题,请通过 support@syncfusion.com 联系我们的支持团队,以获得及时的帮助。

    【讨论】:

      猜你喜欢
      • 2018-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-28
      • 1970-01-01
      • 2021-10-13
      • 1970-01-01
      • 2020-02-10
      相关资源
      最近更新 更多