部分类与自动生成的类部分不匹配

发布于 2024-11-07 23:19:18 字数 682 浏览 0 评论 0原文

我已经为我的数据库类创建了实体模型,这是其中之一:

[EdmEntityTypeAttribute(NamespaceName="SotiModel", Name="SKUPrice")]
[Serializable()]
[DataContractAttribute(IsReference=true)]
public partial class SKUPrice : EntityObject
{
    ...
}

并为其中之一创建了部分类

public partial class SKUPrice
{
}

这里的问题是“部分”世界是用“浅色”颜色编写的,resharper建议:“部分”具有单个部分的类'

似乎我的部分类的“自己”部分与“主要”部分不匹配......

为什么?如何解决这个问题?

PS我在VS2010中工作,在Windows7(64位)下,


我不知道实际上是什么问题,但由于某种原因,如果我将类源代码从一个文件复制/粘贴到另一个文件,然后重命名类名和名称元数据类名 - Visual Studio 不会将其“视为”有效类。

如果我删除带有“损坏”类的文件,并从头开始手动键入所有内容 - 文件被工作室接受......

奇怪而愚蠢的事情......但它是......

I've created entity model for my DB classes, here is one of them:

[EdmEntityTypeAttribute(NamespaceName="SotiModel", Name="SKUPrice")]
[Serializable()]
[DataContractAttribute(IsReference=true)]
public partial class SKUPrice : EntityObject
{
    ...
}

and created partial class for one of them

public partial class SKUPrice
{
}

The problem here is that 'partial' world is written in 'light' color and resharper suggests: 'partial class with a single part'.

It seems like my 'own' part of partial class is not matched to the 'main' part...

Why? How to fix that?

P.S. I'm working in VS2010, under Windows7 (64bit)


I don't know what is actually a problem, but due to some reason if I copy/paste class source code from one file to another and after that rename class name and name of metadata class name - that is not 'considered' by Visual studio as valid class.

If I delete file with that "broken" class, and TYPE EVERYTHING manualy from scratch - file is accepted by studio...

Strange and stupid thing... but it is...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

你在我安 2024-11-14 23:19:18

每个类定义必须位于相同的命名空间中才能正确匹配。

Each class definition must be in the same namespace for them to be correctly matched.

森林很绿却致人迷途 2024-11-14 23:19:18

有类似的问题。尝试重新启动 Visual Studio。

Had a similar problem. Try restarting Visual Studio.

调妓 2024-11-14 23:19:18

这听起来很愚蠢,但请尝试手动输入名称空间。

我的问题与你的类似,在命名空间后添加空格后,resharper 神奇地识别了部分类。我尝试删除空格,它仍然有效。简而言之,源代码文件实际上是相同的,但它们的处理方式有所不同,只是因为命名空间有任何手动键入或非手动键入的痕迹。

对我来说听起来像是 VS bug。

This sounds stupid, but try typing the namespace manually.

My problem is similar to yours, and after adding a space after the namespace, resharper magically recognizes the partial class. I tried removing the space, and it still works. In short, the source code file is virtually the same but they are treated differently just because the namespace has any trace of being typed manually or not.

Sounds like VS bug to me.

风流物 2024-11-14 23:19:18

我知道已经有一段时间了,但我刚刚遇到了这个问题,我注意到我的 x:Class="NAME" 与文件 NAME 不匹配。我也进行了复制和粘贴,但一开始我忽略了进行更改。使名称匹配解决了我遇到的所有问题。

I know it's been a while, but I just ran into this problem and I noticed that my x:Class="NAME" did not match the file NAME. I, too, copied and pasted but I neglected to make that change at first. Making the names matched fixed all issues I was having.

红衣飘飘貌似仙 2024-11-14 23:19:18

我有同样的问题,我通过从 resharper 6.1 降级到 6.0 来解决它,一切正常。
如果您正在使用 resharper,请尝试暂时卸载它。

I have the same issue and I resolve it by downgrading from resharper 6.1 to 6.0 and everything works well.
If you are using resharper try uninstall it temporary.

波浪屿的海角声 2024-11-14 23:19:18

类定义不能跨程序集分布。

Class definitions cannot be spread across assemblies.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文