Silverlight RIA服务中的共享类导致构建错误 - 类型'X'已经包含'Y'的定义, [英] Silverlight Shared classes in RIA service causing build errors -The type 'X' already contains a definition for 'Y'

查看:202
本文介绍了Silverlight RIA服务中的共享类导致构建错误 - 类型'X'已经包含'Y'的定义,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Silverlight 4应用程序,我使用共享类。在.Web项目中,我有一个名为X.Shared.cs的类。这个类有三个字符串属性。当我构建应用程序时,它会给出一个错误,类型'X'已经包含'Y'的定义。看来,Silverlight应用程序中生成的代码中的属性被视为重复的。我已经尝试清洗我的解决方案和重建,这有助于每一次,但是完全不一致。

I have a Silverlight 4 application where I am making use of shared classes. In the .Web project, I have a class called "X.Shared.cs". This class has three string properties. When I build the application, it gives an error saying "The type 'X' already contains a definition for 'Y'". It seems that the properties in the generated code in the Silverlight Application are being seen as duplicates. I have tried cleaning my solution and rebuilding, this helps every now and then but is totally inconsistent.

有没有人有这个问题的经验?

Has anyone had experience in this issue? Am I perhaps doing something wrong?

共享类(X.Shared.cs)的代码如下:

The code for the shared class (X.Shared.cs) is as follows:

public partial class VideoItem
{
    [Key]
    public String ID
    {
        get;
        set;
    }

    public String ImageURL
    {
        get;
        set;
    }

    public String URL
    {
        get;
        set;
    }
}



此处是解决方案资源管理器的屏幕截图,共享文件:

Here is a screenshot of the solution explorer showing the generated shared file:

推荐答案

为了解决这个问题,我创建了一个空白的.shared.cs类,不包含任何属性(这显然是一个部分类)。然后,我在同一个命名空间中创建了另一个部分类与该类名,在这里我把所有需要访问的属性。

To solve this problem, I created a blank .shared.cs class containing no properties (this is obviously a partial class). I then created another partial class in the same namespace with that class name and in here I put all the properties I needed to access.

这篇关于Silverlight RIA服务中的共享类导致构建错误 - 类型'X'已经包含'Y'的定义,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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