"'System' denotes a 'namespace' where a 'class' was expected"

J

Jeremy

I've got two projects, both reference system, system.data and system.xml and
both include the using System.Xml.Serialization and using System at the top
of the file.

Both also include the XmlElementAttribute attribute on some properties as
defined below, but on one project I get the error "'System' denotes a
'namespace' where a 'class' was expected" and the other project I don't.
There highlights the word System on
System.Xml.Schema.XmlSchemaForm.Unqualified and I can't figure out why as
System.Xml.Schema.XmlSchemaForm.Unqualified is an enum, not a namespace.

[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
 
A

Alex Meleta

Hi Jeremy,

How do you use it? E.g. this works fine:

public class AClass
{
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]

int worksFine;
....
}

Regards, Alex
[TechBlog] http://devkids.blogspot.com



J> I've got two projects, both reference system, system.data and
J> system.xml and both include the using System.Xml.Serialization and
J> using System at the top of the file.
J>
J> Both also include the XmlElementAttribute attribute on some
J> properties as defined below, but on one project I get the error
J> "'System' denotes a 'namespace' where a 'class' was expected" and the
J> other project I don't. There highlights the word System on
J> System.Xml.Schema.XmlSchemaForm.Unqualified and I can't figure out
J> why as System.Xml.Schema.XmlSchemaForm.Unqualified is an enum, not a
J> namespace.
J>
J> [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.
J> XmlSchemaForm.Unqualified)]
J>
 
J

Jeremy

This is a copy past of the code that gets the error:

[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string Client_Name;

And this is a copy past of the code that compiles file:

[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string GivenName;

Strange hey? I can't find a difference between the two. This is VS 2003
btw.
 
J

Jeremy

Figured it out, its because I had a property called System. I guess I'll
have to rename the property
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]

public string System;
 
M

Marc Gravell

For reference, theoretically you *can* use some tricks (alias, global
namespace, etc) to allow you to have properties called System etc -
but I really, really don't recommend it. Just mentioning for
completeness.

Marc
 
J

John Vottero

Marc Gravell said:
For reference, theoretically you *can* use some tricks (alias, global
namespace, etc) to allow you to have properties called System etc - but I
really, really don't recommend it. Just mentioning for completeness.

Many years ago, when we were first moving our app to .NET, we had a lot of
discussion about what we would do with our "System". We've had this thing
we call a System for close to 20 years and the natural name would be System
but, that caused a lot of consternation. We finally decided to go ahead and
call it System and, we have no regrets. We didn't have to tell our
installed base that "Systems" are now called "Whatevers" and it doesn't
cause as much pain as we feared.

The biggest problem didn't come up until we converted to V2.0 of the
Framework and changed our string resources to use the resource editor in VS
2005, the code generated by the resource editor sticks a "using System;" in
our namespace which causes a collision. If they would just change that to
"using global::System;", life would be good.

I wouldn't say I recommend it but, if it makes sense for you, do it! It
will work, which is a fine testament to the namespace design of the .NET
environment.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top