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 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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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) {
|
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() { }
}
|
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...
|
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):
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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: 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...
|
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...
|
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...
| | |