[英]Split Asp.Net Core Single Project App into multiple projects - The type conflicts with the imported type in xxx Using the type defined in xxx
I have been splitting my single project Asp.net Core app into different projects and I am seeing some strange errors and warnings and think maybe I have done it wrong.我一直在将我的单个项目 Asp.net 核心应用程序拆分为不同的项目,我看到一些奇怪的错误和警告,我想也许我做错了。 The main warning is that all through my files I have:
主要警告是通过我的所有文件,我拥有:
The type 'VepoContext' in '/Users/benjaminfarquhar/dev/vepo_back_end/Vepo/Vepo.Data/VepoContext.cs' conflicts with the imported type 'VepoContext' in 'Vepo.Data, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
“/Users/benjaminfarquhar/dev/vepo_back_end/Vepo/Vepo.Data/VepoContext.cs”中的类型“VepoContext”与“Vepo.Data”中的导入类型“VepoContext”冲突,版本=0.0.0.0,文化=中性, PublicKeyToken=null'。 Using the type defined in '/Users/benjaminfarquhar/dev/vepo_back_end/Vepo/Vepo.Data/VepoContext.cs'.
使用“/Users/benjaminfarquhar/dev/vepo_back_end/Vepo/Vepo.Data/VepoContext.cs”中定义的类型。 [Vepo, Vepo]csharp(CS0436)
[Vepo, Vepo]csharp(CS0436)
On most of my custom Classes.在我的大多数自定义课程上。
I'm also getting:我也得到:
Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute [Vepo]
重复的 'global::System.Runtime.Versioning.TargetFrameworkAttribute' 属性 [Vepo]
For which I have applied a few of the widely accepted Stack Overflow fixes, which have not worked.为此,我应用了一些被广泛接受的 Stack Overflow 修复程序,但这些修复程序没有奏效。
This is my project structure.这是我的项目结构。 The project named "Vepo" is the Asp.net Core app and the other projects, Vepo.Data, Vepo.Domain, and Vepo.Common are all Class Library projects.
名为“Vepo”的项目是 Asp.net 核心应用程序,其他项目 Vepo.Data、Vepo.Domain 和 Vepo.Common 都是 Class 库项目。 I am wondering if I have placed my data, domain, and common projects inside the Asp.net Core project as it looks like that is the case in VS Code but not in Visual Studio:
我想知道我是否已将我的数据、域和通用项目放在 Asp.net 核心项目中,因为在 VS Code 中是这种情况,但在 Visual Studio 中却不是:
In Visual Studio:在 Visual Studio 中:
In VS Code:在 VS 代码中:
Yes, you have placed your secondary projects inside the actual Vepo project.是的,您已将辅助项目放置在实际的 Vepo 项目中。 However, you also have the ones outside of the main project.
但是,您也有主项目之外的那些。 Make sure to remove the ones inside the main since those are what are most likely causing you to get an error where two of the same types are loaded.
确保删除 main 中的那些,因为它们最有可能导致您在加载两种相同类型时出现错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.