Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 'PATH\Extensions.cs' conflicts with the imported type 'Extensions.MessageDetails' in 'path\lib.dll'. Using the type defined in 'path\Extensions.cs'. path\main.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();     } } 
like image 992
The Mask Avatar asked Nov 10 '11 00:11

The Mask


2 Answers

In my case, with Visual Studio 2013, I found that one of my class libraries had developed a reference to itself. I think it happened when I added a new project to my solution or it was a bug, but either way it was causing this exact issue.

Check your project references for any circular references.

like image 195
James Blake Avatar answered Sep 24 '22 23:09

James Blake


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.

like image 37
parapura rajkumar Avatar answered Sep 25 '22 23:09

parapura rajkumar