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

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

am 31.10.2007 18:10:16 von Kazi

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.Xm l.Schema.XmlSchemaForm.Unqualified)]

Re: ""System" denotes a "namespace" where a "class" was expected"

am 31.10.2007 18:29:12 von 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.Xm l.Schema.
J> XmlSchemaForm.Unqualified)]
J>

Re: ""System" denotes a "namespace" where a "class" was expected"

am 31.10.2007 18:44:57 von Kazi

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

[System.Xml.Serialization.XmlElementAttribute(Form=System.Xm l.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.Xm l.Schema.XmlSchemaForm.Unqualified)]
public string GivenName;

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

"Alex Meleta" wrote in message
news:150f6b305b9168c9ea13d5184b72@msnews.microsoft.com...
> 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.Xm l.Schema.
> J> XmlSchemaForm.Unqualified)]
> J>
>
>

Re: ""System" denotes a "namespace" where a "class" was expected"

am 31.10.2007 19:09:44 von Kazi

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.Xm l.Schema.XmlSchemaForm.Unqualified)]

public string System;





"Alex Meleta" wrote in message
news:150f6b305b9168c9ea13d5184b72@msnews.microsoft.com...
> 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.Xm l.Schema.
> J> XmlSchemaForm.Unqualified)]
> J>
>
>

Re: ""System" denotes a "namespace" where a "class" was expected"

am 02.11.2007 08:48:51 von 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

Re: ""System" denotes a "namespace" where a "class" was expected"

am 02.11.2007 17:39:48 von John Vottero

"Marc Gravell" wrote in message
news:OprL7RSHIHA.3916@TK2MSFTNGP02.phx.gbl...
> 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.