|
Thanks for the hint, I was pretty sure that there was something wron, even if it actually worked!
But it seems that now I have a problem that I don't know how to solve.
I have a class Display that I use to perform all the stuff related to the display, that actually is my control box. For example I need this class because it keeps track whether when the user pushed a button he's beginning a new number or adding a digit to the number currently onscreen. Things like that.
The problem is that I don't know how to access the control that is on the form. You know they are in two different classes. Of course I cannot inside class Display write tbDisplay.Text = "whatever"; nor Form1.tbDisplay; etc.
How this is supposed to work?
Thanky you a lot!
Edward
|
|
|
|
|
Hi everybody!
Whenever I try to instanciate an XmlSerializer I get an FileNotFoundException thrown at me (from mscorlib.dll) with the following information:
File or assembly name hflbt5w2.dll, or one of its dependencies, was not found.
Funny thing is, that each time I run the code the dll-name is a different one!
Can anybody please advise?
Matthias
In theory, there is no difference between theory and practice. In practice, however, there is.
(unknown author)
|
|
|
|
|
|
Hi Leppie,
thanks for your reply. I'm trying just a very simple class. Something like this:
class Test {
// ctors omitted for brevity
public Size _Size;
public Point _Point;
public string _String;
}
I instanciate and set some values, after that I try to serialize the class, but it simply won't work...
thanks again!
Matthias
In theory, there is no difference between theory and practice. In practice, however, there is.
(unknown author)
|
|
|
|
|
|
Hi Leppie,
not, the class is not public, in fact it is a (private) nested class. The serialization stuff is in it's parent class, which is public. And yes, the class has a default ctor.
While I'm writing this I'm trying to write another simple sample. I'll post it here if it doesn't work but let you know otherwise.
Thanks again!
Matthias
In theory, there is no difference between theory and practice. In practice, however, there is.
(unknown author)
|
|
|
|
|
Hi Leppie,
so, here we go... As mentioned in my last post, the class which I want to serialize is nested and private in it's containing class. Thats the problem. As soon as it's been made public, no problem there. It just ruined my design...
a lot of wind for a small boat...
Anyway thanks for your help!!!
Matthias
In theory, there is no difference between theory and practice. In practice, however, there is.
(unknown author)
|
|
|
|
|
leppie wrote:
Sounds like those files ASP.NET makes.
The XML serializer works by creating an Assembly at runtime that handles the serialization of the types to/from XML. Because it generates an Assembly, you wind up with the weird naming scheme.
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|
|
I need to stop/preview the messages that child controls generate. Does anybody know if this can be achieved through subclassing?
For example, I have a textbox on a form, but I don't want the user to be able to set focus to it (So they can't edit and the caret doesn't appear). I want to absorb the msgs if possible or stop controls reacting to them.
Is this possible? or am I
|
|
|
|
|
OOOooh that horrid VB word again
Anyways the answer is yes. Just override the PreProcessMessage() in a derived (subclassed in VB) control. EG:
public class MyTextBox : TextBox {
public override bool PreProcessMessage(ref Message msg)
{
}
}
From MSDN:
All messages are sent to the WndProc method after getting filtered through the PreProcessMessage method.
The WndProc method corresponds to exactly to the Windows WindowProc function. For more information about processing Windows messages, see the WindowProc function documentation in the Windows Platform SDK reference located in the MSDN Library.
Notes to Inheritors: Inheriting controls should call the base class's WndProc method to process any messages that they don't handle.
Cheers
WebBoxes - Yet another collapsable control, but it relies on a "graphics server" for dynamic pretty rounded corners, cool arrows and unlimited font support.
|
|
|
|
|
Why is everyone taking the mick out of VB! I have 10 years experience of 'Application' development in VB. I'd love to move over to c# but unless I've got someone to hold my hand it's never gonna happen and I can't afford classes
I'm perfectly prepared to try and code under c# in a project with help, but there will be a lot of silly questions and I need to get my work done
|
|
|
|
|
LeeDaviesVBSource wrote:
lot of silly questions and I need to get my work done
Ask away! We may not always know what's going on...but somebody will (read: James T. Johnson).
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
Microsoft has reinvented the wheel, this time they made it round.
-Peterchen on VS.NET
|
|
|
|
|
I have this code snipet in my c# classs that generates a string containg xml data.
//build xml data
StringWriter xmlStringWriter = null;
XmlTextWriter xmlWriter = null;
string xmlString = "";
StringBuilder xmlStringBuilder = new StringBuilder();
try
{
xmlStringWriter = new StringWriter(xmlStringBuilder);
xmlWriter = new XmlTextWriter((xmlStringWriter);
xmlWriter.Formatting = Formatting.Indented;
xmlWriter.WriteStartDocument(); //start document
//populate xml
However, the generated xml string contains the header as:
Does anybody know of a way to use enconding "utf-8" when building an xmldoc inside a string?
|
|
|
|
|
|
Thanks leppie.
I tried this solution. I am however getting the error "Property or indexer 'System.IO.TextWriter.Encoding' cannot be assigned to -- it is read only".
Regards,
Andy
|
|
|
|
|
|
|
Hi leppie.
Unfortunately, this did not work either. I got two errors this time:
1. No overload for method 'UTF8StringWriter' takes '1' arguments
2. Property or indexer 'System.IO.TextWriter.Encoding' cannot be assigned to -- it is read only.
Thanks,
Andy
|
|
|
|
|
First of all, there is nothing wrong in getting an UTF-16 encoding (aka Unicode) since you are explicitely outputting a string content whose encoding is, by design, stored as Unicode (all string content in .NET is stored as unicode, like Java by the way).
Next to that, you have a System.Xml.TextWriter(string filename, Encoding enc) constructor ready to help you. Why don't you use it ? UTF-8 is the default encoding if you don't provide one. Then simply use your string content through WriteRaw(string) calls.
Just in case you don't want to tweak your current code, you can achieve what you need (again, that's bad use of the classes) by deriving the Xml.XmlTextWriter class and provide this constructor :
public XmlTextWriter_(TextWriter w, Encoding enc) {
this = new XmlTextWriter_();
this.textWriter = w;
this.encoding = enc;
this.xmlEncoder = new XmlTextEncoder(w, this.encoding);
this.xmlEncoder.QuoteChar = this.quoteChar;
}
PS : train[^] yourself with these free training courses.
|
|
|
|
|
|
Don't know if you are serious, or if you are playing a practical joke on this (on behalf on a semi-drunken state of mind. huh! )
That XmlTextWriter_ class is the derived class. To make it explicit :
public class XmlTextWriter_ : System.Xml.XmlTextWriter
{
...
}
Thus the fields I refer to, and tweak a little bit, are obviously those from the base class. No rocket science here.
|
|
|
|
|
|
You make a point here.
The entire XmlTextWriter class implementation must be rewritten.
Instead, as I pointed first, a better solution is to encode the string itself (whether it's hold by StringWriter, StringBuilder, or even String doesn't matter much) thanks to the Encoding derived classes (System.Text.UTF8Encoding, ...).
|
|
|
|
|
Hi,
I'm just wondering if there is a simple and straightforward way to serialize a class into an XML formatted file. Could somebody pls. point me into the right direction?
Any help is highly appreceated.
Matthias
In theory, there is no difference between theory and practice. In practice, however, there is.
(unknown author)
|
|
|
|