Partial class doesn't match to auto-generated class part
Asked Answered
B

6

9

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...

Billboard answered 17/5, 2011 at 14:41 Comment(2)
some times, that happens when when you have an error code somewhere else. review your codeCytoplast
This question should be closed as "not reproducible". See the bottom part.Lightweight
E
24

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

Equuleus answered 17/5, 2011 at 14:43 Comment(1)
Yes, I just forget to mention: they ARE in the same namespaceBillboard
E
6

Had a similar problem. Try restarting Visual Studio.

Exile answered 17/10, 2013 at 8:43 Comment(2)
It's pretty bad indicator if this is the solution to a lot of build issues with an IDE ...Taunton
This explains nothing.Lightweight
P
4

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.

Possess answered 18/7, 2011 at 4:59 Comment(1)
How very odd - by retyping the namespace did the trick for me in this scenario. Thanks!Huelva
F
1

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.

Filly answered 24/7, 2012 at 19:10 Comment(0)
W
0

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.

Weintraub answered 4/1, 2012 at 15:24 Comment(0)
P
0

Class definitions cannot be spread across assemblies.

Pachydermatous answered 8/6, 2021 at 14:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.