473,396 Members | 2,109 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,396 software developers and data experts.

sub class construtor, super class not holding value

Hi,

I've got a base/super class with just a default constructor. I want another
constructor, but I can't modify the base class, so I created a sub class
with a constructor like so:

public class MySub:MyBase
{
public MySub(string val):base()
{
base.public1="String";
base.public2=val;
}
}

I use it like so:

MyBase myBase=new MySub("sometext");

The class MySub then has no direct references to it, but there is still a
reference to the sub class.

What I'm finding is that if I look at the the value of myBase.public1
under debug (immediately after the assignment has executed), it says Error:
Cannot obtain value, and furthermore, when I try to serialize this class
using XmlSerializer I get an exception:

"An unhandled exception of type 'System.InvalidOperationException' occurred
in system.xml.dll

Additional information: There was an error generating the XML document."

Can someone help me solve the problem?

Thanks

Martin
Nov 16 '05 #1
1 4130
Although the debugger and xmlserializer don't like it, I can correctly
write the base class values to the console.

I reckon this is a xmlserializer issue.

Martin

"Martin" <x@y.z> wrote in message
news:O2**************@TK2MSFTNGP11.phx.gbl...
Hi,

I've got a base/super class with just a default constructor. I want another constructor, but I can't modify the base class, so I created a sub class
with a constructor like so:

public class MySub:MyBase
{
public MySub(string val):base()
{
base.public1="String";
base.public2=val;
}
}

I use it like so:

MyBase myBase=new MySub("sometext");

The class MySub then has no direct references to it, but there is still a
reference to the sub class.

What I'm finding is that if I look at the the value of myBase.public1
under debug (immediately after the assignment has executed), it says Error: Cannot obtain value, and furthermore, when I try to serialize this class
using XmlSerializer I get an exception:

"An unhandled exception of type 'System.InvalidOperationException' occurred in system.xml.dll

Additional information: There was an error generating the XML document."

Can someone help me solve the problem?

Thanks

Martin

Nov 16 '05 #2

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

Similar topics

0
by: Shaun Marshall | last post by:
Hope someone can help, for an assignment i was given a starter application package, with that starter package i had to create some employee classes and test harnesses. below iv pasted my Container...
2
by: Ovid | last post by:
Hi, I'm trying to determine the cleanest way to override class data in a subclass. class Universe { public String name; private static double PI = 3.1415; Universe(String name) {
8
by: Pent | last post by:
Hi All, Why is this code valid? How can the static ctor be used? It doesn't act as class ctor at all. struct A { static A() { } }
4
by: Pupeno | last post by:
Hello, I want to jump over a method in the class hierarchy, that is: If I have class A(object), clas B(A), class C(B) and in C, I want a method to do exactly what A does but not what B does in...
4
by: ddtl | last post by:
Hello everybody. Consider the following code: class A(object): def met(self): print 'A.met' class B(A): def met(self):
3
by: Belebele | last post by:
I have an Element class which is abstract and I would like to have an object of the Iterator class to iterate over a range of elements. I would like to use std::for_each to instrument the...
4
by: GesterX | last post by:
Hi guys, this has been bugging me for a while and I'd appreciate any help anyone could offer. Basically I am running a boating simulation and I have all of the "harder" parts done but one error is...
1
by: madman228 | last post by:
Hi guys I have run in to a littl bit of trouble. I am writing a class called polynomial in which i need a derivative method I have everything, just dont know how to start the derivative method. Any...
11
by: Rafe | last post by:
Hi, I'm working within an application (making a lot of wrappers), but the application is not case sensitive. For example, Typing obj.name, obj.Name, or even object.naMe is all fine (as far as...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.