【问题标题】:Replacing class reference from "built-in" assembly with out-of-band assembly using Visual Studio 2019 Preview for Mac使用 Visual Studio 2019 Preview for Mac 将“内置”程序集中的类引用替换为带外程序集
【发布时间】:2019-07-09 23:01:24
【问题描述】:

背景: 我目前正在尝试使用 EF6 连接到 MySQL 数据库,并正在寻找关于 not being able to be loaded from an assembly 类型的 an error message 的解析。我相信我已经找到了一个可能的解决方案,使用out-of-band release of a different assembly that includes the class,但该解决方案产生了另一个问题,它似乎与第一个问题完全不同,可以作为它自己的问题(即使回答一个问题可能同时回答两个问题)。

问题:如何使用 Visual Studio 2019 Preview for Mac 包含带外程序集,让我可以使用程序集中的特定类?我想使用System.Component.Annotations3.0 preview release 来获得EF 所需的AssociatedMetadataTypeTypeDescriptionProvider 类。当我尝试遵循 instructions for adding an OOB assembly 并重建我的项目时,会引发异常,指示似乎也包含该类的不同程序集的旧版本。

包控制台输出:

Successfully installed 'System.ComponentModel.Annotations 4.6.0-preview.18571.3' to Ef2MySql

例外:

TypeLoadException: Could not load type 'System.ComponentModel.DataAnnotations.AssociatedMetadataTypeTypeDescriptionProvider' from assembly 'System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

编辑: 我刚刚检查了AssociatedMetadataTypeTypeDescriptionProvider 是否在 NuGet 包中,方法是在一个不相关的空目录中运行 nuget install System.ComponentModel.Annotations -Version 4.6.0-preview.19073.11,然后他们使用 VS 打开 System.ComponentModel.Annotations.4.6.0-preview.19073.11/lib/net461/System.ComponentModel.Annotations.dll . 但是,它不在 NuGet 包中的所有 DLL 中。只是net461 中的那个。

进一步编辑: 但是,将我验证的程序集添加为 .NET 程序集(而不是在 VS 中使用 NuGet)仍然无法解决错误.

【问题讨论】:

  • 我创建了一个新项目并安装了System.ComponentModel.Annotations 4.6.0-preview.19073.11并安装了最新的EntityFramework,重建我的项目并没有出现任何错误。我还需要做其他事情来重现您的问题吗?似乎也包含该类的不同程序集是什么?
  • 感谢@JackHua-MSFT 的回复。错误是一个例外;我编辑了这个问题以澄清这一点。 Microsoft 文档中为 System.ComponentModel.DataAnnotations 命名空间中的 AssociatedMetadataTypeTypeDescriptionProvider 类列出的两个程序集是 System.ComponentModel.DataAnnotations.dll 和 System.ComponentModel.Annotations.dll。
  • 我只是用 nuget 命令做了一点检查,发现该类不在 nuget 包中的所有程序集版本中。
  • 你最好直接向微软报告,github.com/aspnet/EntityFramework6/issues

标签: .net xamarin visual-studio-mac visual-studio-2019


【解决方案1】:

## 考虑使用 sqlite ##

Microsoft RazorPagesMovie 教程在 Visual Studio 2019 for Mac 中使用 sqlite 而不是 mysql


(尝试修改它以包含您的问题,希望您可以从中学到足够的东西来帮助您解决mysql问题)

  1. 关注Tutorial: Get started with Razor Pages in ASP.NET Core
  2. 还有第二部分:Add a model to a Razor Pages app in ASP.NET Core

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-03-26
    • 1970-01-01
    • 2010-10-17
    • 1970-01-01
    • 2017-06-06
    • 1970-01-01
    • 2015-10-31
    • 1970-01-01
    相关资源
    最近更新 更多