Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
318 views
in Technique[技术] by (71.8m points)

c# - Warning “The type X in Y.cs conflicts with the imported type X in Z.dll”

The main.cs of my project returns the following warning:

Warning 1 The type 'Extensions.MessageDetails' in 'PATHExtensions.cs' conflicts with the imported type 'Extensions.MessageDetails' in 'pathlib.dll'. Using the type defined in 'pathExtensions.cs'. pathmain.cs

What is wrong with my project? How to get rid of the warning?

The code of my project has the following structure:

Extensions.cs

namespace Extensions
{

    public class MessageDetails
    {
        public string message { get; set; }
        public string link { get; set; }
        public string picture { get; set; }
        public string name { get; set; }
        public string caption { get; set; }
        public string description { get; set; }
        public string userid { get; set; }
        public string username { get; set; }

        public object actions { get; set; }
        public object privacy { get; set; }
        public object targeting { get; set; }
    }

}

lib.dll

namespace MyClassLib {

    public class MyClassLibFoo {
        public void foo(MessageDetails parameters) {
            /* .. */
        }
    }

}

main.cs

using MyClassLib;
using Extensions;

class Program
{
    static void Main(string[] args)
    {
        MessageDetails md = new MessageDetails();
    }
}
question from:https://stackoverflow.com/questions/8073806/warning-the-type-x-in-y-cs-conflicts-with-the-imported-type-x-in-z-dll

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It seems like Extensions.cs is both part of the project that builds lib.dll and your main.exe

Remove it from one of the project to fix this issue.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...