我怎样才能解决这个问题?单位类型的两个DLL文件存在 [英] How can I resolve this? The unit type exists in two dll files

查看:453
本文介绍了我怎样才能解决这个问题?单位类型的两个DLL文件存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在经历使用Visual Studio 11 Beta版的教程。当试图设置字段值的最大长度在我的一类:

I am currently going through a tutorial using Visual Studio 11 beta. When trying to set the max length of a field value in one of my classes:

[MaxLength(50)]
public string LastName { get; set; }

它的错误并不会让我编译,因为在两个地方存在最大长度()功能:

错误4类型 System.ComponentModel.DataAnnotations .MaxLengthAttribute同时存在于C:\\用户\\我\\文档\\ Visual Studio的11 \\ ContosoUniversity \\包\\ EntityFramework.4.1.10331.0 \\ LIB \\ net40 \\ EntityFramework.dll'和'C:\\ Program Files文件(x86)的\\参考大会\\微软\\ Framework.NETFramework \\ V4.5 \\ System.ComponentModel.DataAnnotations.dll

Error 4 The type 'System.ComponentModel.DataAnnotations.MaxLengthAttribute' exists in both 'c:\Users\me\Documents\Visual Studio 11\ContosoUniversity\packages\EntityFramework.4.1.10331.0\lib\net40\EntityFramework.dll' and 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\System.ComponentModel.DataAnnotations.dll'

我试图删除这两个文件,​​但只是导致更多的问题,因为在我的项目其他code是依赖于他们。

I have tried to remove both files but that just causes more issues because other code in my project is dependent upon them.

有没有一种方法,我可以告诉它使用一个或其他?

Is there a way I can tell it to use one or the other?

所有这些方法似乎并没有为我工作..参考意见答案..下任何其他的想法?

感谢

推荐答案

与所需的命名空间限定属性

Qualify the attribute with the desired namespace

[System.ComponentModel.DataAnnotations.MaxLength(50)]
public string LastName { get; set; } 

这篇关于我怎样才能解决这个问题?单位类型的两个DLL文件存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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