简体   繁体   English

使用Visual Studio 2019 Preview for Mac从带内置程序集的``内置''程序集替换类引用

[英]Replacing class reference from “built-in” assembly with out-of-band assembly using Visual Studio 2019 Preview for Mac

Background: I'm currently trying to use EF6 to connect to a MySQL database and am searching for a resolution to an error message about a type not being able to be loaded from an assembly . 背景:我目前正在尝试使用EF6连接到MySQL数据库,并正在寻找有关无法从程序集中加载类型的错误消息的解决方案。 I believe I've found a possible solution, using an out-of-band release of a different assembly that includes the class , but that solution has yielded yet another question that seems to be distinct enough from the first to be its own question (even though answering one question may answer both). 我相信我已经找到了一个可能的解决方案,使用带类的另一个程序集的带外发行版 ,但是该解决方案产生了另一个问题,该问题似乎与第一个问题截然不同,它本身就是一个问题(即使回答一个问题可能会回答两个问题)。

Question: How can I include an out-of-band assembly using Visual Studio 2019 Preview for Mac in a way that lets me use a specific class from the assembly? 问题:如何以允许我使用程序集中的特定类的方式使用Mac版Visual Studio 2019 Preview包含带外程序集? I'd like to use the 3.0 preview release of System.Component.Annotations to get at the AssociatedMetadataTypeTypeDescriptionProvider class required by EF. 我想使用System.Component.Annotations3.0预览版来获得EF所需的AssociatedMetadataTypeTypeDescriptionProvider类。 When I try to follow the instructions for adding an OOB assembly and rebuild my project, an exception gets thrown indicating that the old version of a different assembly that seems to also include that class. 当我尝试按照说明添加OOB程序集并重建我的项目时,将引发异常,表明另一个程序集的旧版本似乎也包含该类。

Package Console Output: 软件包控制台输出:

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

Exception: 例外:

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

edit: I just checked that AssociatedMetadataTypeTypeDescriptionProvider is in the NuGet package by running nuget install System.ComponentModel.Annotations -Version 4.6.0-preview.19073.11 in an unrelated, empty directory and them opening System.ComponentModel.Annotations.4.6.0-preview.19073.11/lib/net461/System.ComponentModel.Annotations.dll with VS. 编辑:我只是通过在不相关的空目录中运行nuget install System.ComponentModel.Annotations -Version 4.6.0-preview.19073.11并检查它们是否打开System.ComponentModel.Annotations.4.6.0-preview.19073.11/lib/net461/System.ComponentModel.Annotations.dll ,来检查AssociatedMetadataTypeTypeDescriptionProvider是否在NuGet包中。 System.ComponentModel.Annotations.4.6.0-preview.19073.11/lib/net461/System.ComponentModel.Annotations.dll与VS。 However, it's not in all of the DLLs in the NuGet package. 但是,它不是在NuGet包的所有DLL中都包含。 Just the one in net461 . 只是net461中的net461

further edit: However, adding the assembly that I verified has the class as an .NET assembly (rather than using NuGet in VS) still does not resolve the error. 进一步编辑:但是,添加我验证的程序集将其类作为.NET程序集(而不是在VS中使用NuGet)仍然无法解决该错误。

屏幕截图显示了装配中的类

## Consider using sqlite instead ## ##考虑使用sqlite代替##

Microsoft RazorPagesMovie tutorial using sqlite instead of mysql in Visual Studio 2019 for Mac: 在Mac的Visual Studio 2019中使用sqlite代替mysql的 Microsoft RazorPagesMovie教程:


(Try to modify it to include your issue, and hopefully you may learn from it enough to help you resolve your issues with mysql) (尝试修改它以包括您的问题,希望您可以从中学到足够的知识来帮助您解决mysql问题)

  1. Follow Tutorial: Get started with Razor Pages in ASP.NET Core 遵循教程:ASP.NET Core中的Razor页面入门
  2. And the second part: Add a model to a Razor Pages app in ASP.NET Core 第二部分: 在ASP.NET Core中向Razor Pages应用添加模型

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

相关问题 Visual Studio mac 2019(社区) - PresentationCore - 未找到 .Net Framework 4 的程序集 - Visual Studio mac 2019 (Community) - PresentationCore - Assembly not found for .Net Framework 4 Visual Studio:查找类的程序集 - Visual Studio: Find the assembly of a class 参考可以替代Visual Studio 2010中的参考程序集吗? - Reference alternate to reference assembly in Visual Studio 2010? 在Visual Studio 2013中缺少使用指令或程序集引用 - missing a using directive or an assembly reference in visual studio 2013 .NET Visual Studio使用来自NuGet的引用导致无法加载文件或程序集 - .NET Visual Studio using reference from NuGet causes Could not load file or assembly 如何使用 Visual Studio 2017 创建参考程序集 - How to create a Reference Assembly with Visual Studio 2017 如何在没有 Visual Studio 的情况下引用程序集(* .dll)? - How to reference an assembly(*.dll) without visual studio? 如何在Visual Studio中抑制程序集引用警告? - How to suppress assembly reference warnings in Visual Studio? Visual Studio:缺少对“Windows”的程序集引用 - Visual Studio: Missing assembly reference to “Windows” 在Visual Studio中签署程序集 - Signing an assembly in Visual Studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM