473,382 Members | 1,648 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How to tame CS0108 ("new" required) errors

I use XMLspy for handling XML files and started testing its feature to generate
C# code from XML Schemas. Now I got stuck in a strange situation: (I have to
add being not a C# geek, only currently looking deeper into C# considering
making more use of it)

I created C# code from a schema with XMLspy 2005 rel 1. This code worked
flawlessly.

Then I moved to XMLspy 2005 rel. 3 and created C# code from exactly the same
schema again - and ran into a ton of CS0108 errors:

This generated code creates derived classes (as XML Schema types might be
derived from another type). VS2003 raises warnings on a method called Validate
which exists in the base class and in the derived class and VS2003 tells the
"new" keyword is required since the Validate method of the derived class hides
the Validate class of the initial class. This sounds reasonable.

BUT: how does it come to get the rel.1 code compiled without this warning as
the code looks completely the same as the rel.3 code? Is there a VS2003 switch
(in the Project settings ?) to let the methods of the derived class hide the
ones of the base class automatically?

Thanks for any glue

Michael

Nov 17 '05 #1
2 5441
>
BUT: how does it come to get the rel.1 code compiled without this warning
as
the code looks completely the same as the rel.3 code? Is there a VS2003
switch
(in the Project settings ?) to let the methods of the derived class hide
the
ones of the base class automatically?
Could you possibly post some sample code? My best guess is\was that there is
a bug in XMLSpy(either in rel1 or rel3) that is causing this issue.

Now, the compiler will hide methods automatically already, thats why CS0108
is awarning, not an error. You have two options. One is to set your warning
level to level 1 warnings and thus ignoring many valueable warnings, but
that would be a very bad thing. The second is the Supress Sepcific Warnings
setting; you should be able to add 108 to that list and the compiler won't
issue that warning.

Both of these options can be found in project properties under Configuration
Properties->Build
Thanks for any glue

Michael

Nov 17 '05 #2
Jon Skeet [C# MVP] <sk***@pobox.com> wrote:
Michael Steidl <m.********@anonymus.org> wrote:
>Now, the compiler will hide methods automatically already, thats why CS0108
>is awarning, not an error. You have two options. One is to set your warning
>level to level 1 warnings and thus ignoring many valueable warnings, but
>that would be a very bad thing. The second is the Supress Sepcific
>Warnings
>setting; you should be able to add 108 to that list and the compiler won't
>issue that warning.
This is an excerpt from the code generated by XMLspy: the base class
ShortStringType and a class CarBrandsType derived from it:
(the base class SchemaString is part of the Altova/XMLspy types library,
this
class has no "Validate" method )
Both projects are set to a warning level of 4


The old code should generate a warning too. Have you tried doing a full
rebuild with it? Just to prove that the base method is present in the
old code, try calling base.Validate() from CarBrandsType.Validate().


Right, a full rebuild showed the same warnings. In the meantime I got a notice
from the
makers of XMLspy saying this is a bug with their code generator and they will
fix it.

Thanks for your help

Michael

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Vencz Istv?n | last post by:
I have a web application installed on Windows 2003 Standard Edition with SP1, it accesses a SQL Servet 2000 database installed on Windows 2000 Server, the two computers are not in the same domain....
18
by: Leslaw Bieniasz | last post by:
Cracow, 28.10.2004 Hello, I have a program that intensively allocates and deletes lots of relatively small objects, using "new" operator. The objects themselves are composed of smaller...
24
by: Rv5 | last post by:
Rookie c++ question, but Ive spent the last 5 years doing Java, where everytime I created an object I used new. In c++ I can create my objects without and its confusing me just a little. I have...
5
by: Mark P | last post by:
I think my previous posts on this subject are too verbose and are scaring off replies so I'll keep this one brief: If I define my own operator new(size_t size) in a class, does that...
12
by: Olaf Baeyens | last post by:
I am porting some of my buffer class code for C++ to C#. This C++ class allocates a block of memory using m_pBuffer=new BYTE; But since the class is also used for pointers for funtions that uses...
0
by: Michael Steidl | last post by:
I use XMLspy for handling XML files and started testing its feature to generate C# code from XML Schemas. Now I got stuck in a strange situation: (I have to add being not a C# geek, only currently...
37
by: jht5945 | last post by:
For example I wrote a function: function Func() { // do something } we can call it like: var obj = new Func(); // call it as a constructor or var result = Func(); // call it as...
36
by: Pat | last post by:
Hi, I've run into a strange problem, but one that seems like it might be fairly common. I have a single base class, from which several other classes are derived. To keep the example simple,...
30
by: Medvedev | last post by:
i see serveral source codes , and i found they almost only use "new" and "delete" keywords to make they object. Why should i do that , and as i know the object is going to be destroy by itself at...
3
by: tvnaidu | last post by:
I compiled tinyxml files (.cpp files) and when I am linking to create final exe in Linux, I am getting lot of errors saying "undefiend reference" to "operator new" and "delete", any idea?. ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.