警告:“在与Z.dll进口X型Y.cs冲突的类型X” [英] Warning “The type X in Y.cs conflicts with the imported type X in Z.dll”

查看:127
本文介绍了警告:“在与Z.dll进口X型Y.cs冲突的类型X”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

main.cs 我的项目返回以下警告:




警告1型'扩展在'PATH\Extensions.cs'在'path\lib.dll Extensions.MessageDetails'与进口类型冲突'.MessageDetails。使用在'path\Extensions.cs'所定义的类型。 path\main.cs




什么是错我的项目? ?如何摆脱的警告



我的项目的代码结构如下:



Extensions.cs

 命名空间扩展
{

公共类MessageDetails
{
公共字符串消息{搞定;组; }
公共字符串链接{搞定;组; }
公共字符串图片{搞定;组; }
公共字符串名称{;组; }
公共字符串的标题{搞定;组; }
公共字符串描述{搞定;组; }
公共字符串用户标识{搞​​定;组; }
公共字符串的用户名{获得;组; }

公共对象行动{搞定;组; }
公共对象的隐私得到{;组; }
公共对象定位{搞定;组; }
}

}



lib.dll

 命名空间MyClassLib {

公共类MyClassLibFoo {
公共无效美孚(MessageDetails参数){
/ *。* /
}
}

}

main.cs

 使用MyClassLib;使用扩展
;

类节目
{
静态无效的主要(字串[] args)
{
MessageDetails MD =新MessageDetails();
}
}


解决方案

据好像Extensions.cs是对项目的一部分建立 lib.dll 并您的 MAIN.EXE



从一个删除它来解决这个问题。


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();
    }
}

解决方案

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

Remove it from one to fix this issue.

这篇关于警告:“在与Z.dll进口X型Y.cs冲突的类型X”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆