组织类文件会导致与VS 2017中的导入类型警告冲突 [英] Organizing class files causes conflicts with imported type warnings in VS 2017
问题描述
警告 CS0436
"对象"类型'C:\ MyProj\App_Code \ Objects.cs'与'MyProj,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null'中的导入类型'Objects'冲突。使用'C:\ MyProj \ App_Code \ Objectss.cs'中定义的类型。
Warning CS0436 The type 'Objects' in 'C:\MyProj\App_Code\Objects.cs' conflicts with the imported type 'Objects' in 'MyProj, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'C:\MyProj\App_Code\Objects.cs'.
当我移动Object.cs时到根文件夹,警告消失了。但是将其移动到App_Code文件夹会导致警告重新出现。可能有什么问题?
When I move the Object.cs to the root folder, the warning goes away. But moving it into App_Code folder causes the warning to reappear. What could be wrong?
推荐答案
你好Chandra.Sekhar,
欢迎来到MSDN论坛。
请查看此文档:
https://docs.microsoft.com/en-us/dotnet/csharp/misc/cs0436
原因是类型冲突。正如Docs所提到的,当源文件(file_2)中的类型与文件_1中的导入类型冲突时,会发出此警告。编译器
使用源文件中的那个。
因此,当您将Object.cs移动到根文件夹时,警告就会消失。
希望我的回复能为您提供帮助。
最好的问候
5月
这篇关于组织类文件会导致与VS 2017中的导入类型警告冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!