|
thanks it worked fine for my application
|
|
|
|
|
|
How can i load in a XmlDocument an xml file (from text file) that in the tag contain any type of char ? How can encode this ?
If my file contain char as "&" or "°" there is an exception (Xml.XmlException Errore durante l'analisi di EntityName).
I try with this but don't work:
Encoding enc = Encoding.ASCII;
FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.None);
StreamReader sr = new StreamReader(fs,enc);
string response = sr.ReadToEnd();
XmlDocument xml = new XmlDocument();
xml.LoadXml(response);
fs.Close();
sr.Close();
The exception is Xml.XmlException Errore durante l'analisi di EntityName.
|
|
|
|
|
Well as far as I know it is not allowed to use all chars in entity-names. There is a strict rule for tag-names. Maybe you could post a bit of your xml-file, so that we can identify the problem.
Regards
Sebastian
|
|
|
|
|
The problem isn't the tag-names but their content.
The exception occur when in the content of a tag (<tag> abc & avc n° ) there are particular char as & or °
|
|
|
|
|
You could replace all special characters with their escape characters before reading the xml. Maybe this helps.
|
|
|
|
|
How can i replace it ? can you give me an example of code ?
|
|
|
|
|
Not the best method but maybe
response = response.Replace( "&", "&");
By the way, do you have an xml-declaration in your file (sort of <?xml version="1.0" encoding="UTF-8"?> )?
|
|
|
|
|
I dont' have an xml-declaration...however if i add it there is always the same exception.
To use replace i must know all possible incorrect char... i would like to find a method valid for all possible char that may occur in the file.
Edit:
if i use utf8 encoding and replace of &, program work well with my current file xml.
I hope in future don't occur another char that create same problem. I think that & is properly of XML standard and so cause this exception.
modified on Wednesday, June 17, 2009 8:14 AM
|
|
|
|
|
If the file doesn't contain a well-formed XML document you'll need to fix it.
|
|
|
|
|
For the moment i use utf8 encoding and replace all the & with &
What are the other possible char that may cause the Exception ?
|
|
|
|
|
|
I am using abstract classes in my project, meanwhile i want to use overloaded Constructors to those classes, then how to call those overloaded constructors, because abstract classes cannot instantiate.
can any one please answer me?
Thanks in advance...
|
|
|
|
|
An abstract class can have implementations though.
public abstract class BaseClass
{
protected BaseClass()
{ }
protected BaseClass(int id)
{
ID = id;
}
public int ID
{
get;
private set;
}
public string Text
{
get;
internal set;
}
}
public class DerivedClass : BaseClass
{
public DerivedClass() : base() { }
public DerivedClass(int id) : base(id) { }
public DerivedClass(int id, string text) : base(id)
{
Text = text;
}
}
[Edit] Forgot to mark the abstract class's constructors as protected[/Edit]
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
modified on Wednesday, June 17, 2009 4:57 AM
|
|
|
|
|
The same as calling any base class constructors?
|
|
|
|
|
i'm try to register a formclosing event with a button click event but i get the error saying "Cannot assign to 'button1_Click' because it is a 'method group'"
this is the code i'm using
private void Form1_FormClosing(object sender,EventArgs e)
{
DialogResult ds = MessageBox.Show("exit?", "exit", MessageBoxButtons.YesNo);
FormClosingEventArgs ee = (FormClosingEventArgs)e;
if (ds == DialogResult.Yes)
{
ee.Cancel = false;
}
else
{
ee.Cancel = true;
}
}
private void Form1_Load(object sender, EventArgs e)
{
button1_Click+= Form1_FormClosing;
}
what might be the problem here ?
|
|
|
|
|
prasadbuddhika wrote: button1_Click+= Form1_FormClosing;
well you dont add event handlers like that. try...
button1.Click += new EventHandler(Form1_FormClosing);
but your Form1_FormClosing method is just a handler and will not close the form.
what you should do is have the FormClosing handler on the Form.Closing event. Then have the button click event call
Form.Close();
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
button1_Click is a method. I think you meant button1.Click
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
oh ! great , thanx,i really deceived , thank you again.
|
|
|
|
|
in my app there is a button called exit, i want to prompt a dialog box confirming the exit.now i'm trying handle the closing event of the control box, that is why i'm trying to register the formclosing event with click event , but i get a deligate problem because of eventarg and formclosingeventarg, so any one can help me with this
|
|
|
|
|
Hi,
In your original code the signature of the delegate is incorrect
[Edit: typo corrected]
private void Form1_FormClosing(object sender, EventArgs e)
should be
private void Form1_FormClosing(object sender, FormClosingEventArgs e).
Alan.
modified on Wednesday, June 17, 2009 6:23 AM
|
|
|
|
|
This is pretty simple. You need to call Close from the button's Click event handler and display the message box or whatever in the form's FormClosing event handler, setting e.Cancel if you don't want to close:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
FormClosing += new FormClosingEventHandler(Form1_FormClosing);
btnExit.Click += new EventHandler(btnExit_Click);
}
void btnExit_Click(object sender, EventArgs e)
{
Close();
}
void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = (MessageBox.Show(
this,
"Do you really wish to exit this application?",
"Confirm Exit",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button2) != DialogResult.Yes);
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I wondered about that when I saw your original code.
private void Form1_FormClosing(object sender,EventArgs e)
{
DialogResult ds = MessageBox.Show("exit?", "exit", MessageBoxButtons.YesNo);
FormClosingEventArgs ee = (FormClosingEventArgs)e;
if (ds == DialogResult.Yes)
{
ee.Cancel = false;
}
else
{
ee.Cancel = true;
}
}
private void Form1_Load(object sender, EventArgs e)
{
button1_Click+= Form1_FormClosing;
}
Are you perhaps thinking that linking the ForClosing event to a button click will cause the button to generate the FormClosing event and thus close the form? If so, that will not happen.
What you need to do in your button Click event is "this.Close()" which will close the current form. That will raise the FormClosing event where you can then ask for confirmation:
private void Form1_FormClosing(object sender,EventArgs e)
{
DialogResult ds = MessageBox.Show("exit?", "exit", MessageBoxButtons.YesNo);
if (e is FormClosingEventArgs)
{
FormClosingEventArgs ee = e as FormClosingEventArgs;
ee.Cancel = (ds == DialogResult.No);
}
}
private void Button1_Click(object sender, EventArgs e)
{
this.Close();
}
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
iam using windows application using csharp,iam design UI which will display the all characters of keyboard(lowercase,uppercase,symbols,special characters)I initialize the characters using folowing code:
code 1. private void InitializeCharacters(InkOverlay inkOverlay)
{
this.Add(new Character(inkOverlay, "0x20", "space", " ", CharClass.Hidden));
this.Add(new Character(inkOverlay, "0x21", "exclam", "!", CharClass.Punctuation));
this.Add(new Character(inkOverlay, "0x22", "quotedbl", "\"", CharClass.Punctuation));
this.Add(new Character(inkOverlay, "0x23", "numbersign", "#", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x24", "dollar", "$", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x25", "percent", "%", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x26", "ampersand", "&", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x27", "quotesingle", "'",CharClass.Punctuation));
this.Add(new Character(inkOverlay, "0x28", "parenleft", "(", CharClass.Punctuation));
this.Add(new Character(inkOverlay, "0x29", "parenright", ")", CharClass.Punctuation));
this.Add(new Character(inkOverlay, "0x2a", "asterisk", "*", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x2b", "plus", "+", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x2c", "comma", ",", CharClass.Punctuation));
this.Add(new Character(inkOverlay, "0x2d", "hyphen", "-", CharClass.Punctuation));
this.Add(new Character(inkOverlay, "0x2e", "period", ".", CharClass.Punctuation));
this.Add(new Character(inkOverlay, "0x2f", "slash", "/", CharClass.Punctuation));
this.Add(new Character(inkOverlay, "0x30", "zero", "0", CharClass.Number));
this.Add(new Character(inkOverlay, "0x31", "one", "1", CharClass.Number));
this.Add(new Character(inkOverlay, "0x32", "two", "2", CharClass.Number));
this.Add(new Character(inkOverlay, "0x33", "three", "3", CharClass.Number));
this.Add(new Character(inkOverlay, "0x34", "four", "4", CharClass.Number));
this.Add(new Character(inkOverlay, "0x35", "five", "5", CharClass.Number));
this.Add(new Character(inkOverlay, "0x36", "six", "6", CharClass.Number));
this.Add(new Character(inkOverlay, "0x37", "seven", "7", CharClass.Number));
this.Add(new Character(inkOverlay, "0x38", "eight", "8", CharClass.Number));
this.Add(new Character(inkOverlay, "0x39", "nine", "9", CharClass.Number));
this.Add(new Character(inkOverlay, "0x3a", "colon", ":", CharClass.Punctuation));
this.Add(new Character(inkOverlay, "0x3b", "semicolon", ";", CharClass.Punctuation));
this.Add(new Character(inkOverlay, "0x3c", "less", "<", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x3d", "equal", "=", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x3e", "greater", ">", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x4f", "question", "?", CharClass.Punctuation));
this.Add(new Character(inkOverlay, "0x40", "at", "@", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x41", "A", "A", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x42", "B", "B", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x43", "C", "C", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x44", "D", "D", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x45", "E", "E", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x46", "F", "F", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x47", "G", "G", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x48", "H", "H", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x49", "I", "I", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x4a", "J", "J", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x4b", "K", "K", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x4c", "L", "L", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x4d", "M", "M", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x4e", "N", "N", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x4f", "O", "O", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x50", "P", "P", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x51", "Q", "Q", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x52", "R", "R", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x53", "S", "S", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x54", "T", "T", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x55", "U", "U", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x56", "V", "V", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x57", "W", "W", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x58", "X", "X", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x59", "Y", "Y", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x5a", "Z", "Z", CharClass.Uppercase));
this.Add(new Character(inkOverlay, "0x5b", "bracketleft", "[", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x5c", "backslash", @"\", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x5d", "bracketright", "]", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x5e", "asciicircum", "^", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x5f", "underscore", "_", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x60", "grave", "`", CharClass.Notdef));
this.Add(new Character(inkOverlay, "0x61", "a", "a", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x62", "b", "b", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x63", "c", "c", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x64", "d", "d", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x65", "e", "e", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x66", "f", "f", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x67", "g", "g", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x68", "h", "h", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x69", "i", "i", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x6a", "j", "j", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x6b", "k", "k", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x6c", "l", "l", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x6d", "m", "m", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x6e", "n", "n", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x6f", "o", "o", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x70", "p", "p", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x71", "q", "q", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x72", "r", "r", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x73", "s", "s", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x74", "t", "t", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x75", "u", "u", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x76", "v", "v", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x77", "w", "w", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x78", "x", "x", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x79", "y", "y", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x7a", "z", "z", CharClass.Lowercase));
this.Add(new Character(inkOverlay, "0x7b", "braceleft", "{", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x7c", "bar", "Signature ", CharClass.Signature));
this.Add(new Character(inkOverlay, "0x7d", "braceright", "}", CharClass.Symbol));
this.Add(new Character(inkOverlay, "0x7e", "asciitilde", "~", CharClass.Symbol));
}
///Above code works fine... i have used picturebox control to draw the writing area
private void drawWritingArea()
{
this.drawWritingArea(this.picBoxCharacters.Width);
}
///The error comes here when it goes into for each loop for each charset, from the code1 i get the all characters into charset it there works fine but during FOR LOOP it gives me error at charset (Stack overflow execption , please suggest me how to resolve it)//
private void drawWritingArea(int bitmapWidth)
{
Application.DoEvents();
CharClass[] classArray2 = new CharClass[6];
classArray2[1] = CharClass.Uppercase;
classArray2[2] = CharClass.Number;
classArray2[3] = CharClass.Punctuation;
classArray2[4] = CharClass.Symbol;
classArray2[5] = CharClass.Signature;
CharClass[] classArray = classArray2;
int num = 0x20;
int num2 = num / 4;
int num3 = num / 2;
int num4 = 13;
int num5 = 0x37;
int num6 = 10;
int num7 = 10;
double num8 = double.Parse(this.lblZoomFactor.Text) / 100.0;
int num9 = (int)(num * num8);
int num10 = (int)(num2 * num8);
int num11 = (int)(num3 * num8);
int width = (int)(num5 * num8);
int num13 = (int)(num6 * num8);
int height = ((num4 + num9) + num10) + num11;
int num15 = ((bitmapWidth - 0x10) - (2 * num13)) / width;
int num16 = (bitmapWidth - (2 * num6)) - (width * num15);
num16 /= 2;
int num17 = 0;
Label_0104:
foreach (Character character in this.charSet)///Error of stack overflow execption in Charset//
{
foreach (CharClass class2 in classArray)
{
if (character.type == class2)
{
num17++;
goto Label_0104;
}
}
}
int num18 = (num17 / num15) + 4;
if (this.breakCharTypes)
{
num18 += 2;
}
int num19 = num18 * (height + num13);
Bitmap image = new Bitmap(bitmapWidth, num19, PixelFormat.Format32bppArgb);
this.picBoxCharacters.Height = num19;
Graphics graphics = Graphics.FromImage(image);
graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
Brush brush = new SolidBrush(Color.LightYellow);
Pen pen = new Pen(Color.LightSteelBlue);
Pen pen2 = new Pen(Color.DarkBlue, 2f);
Pen pen3 = new Pen(Color.Gainsboro);
pen3.DashStyle = DashStyle.Dash;
Brush brush2 = new SolidBrush(Color.DimGray);
int y = num13;
int num21 = 0;
for (int i = 0; i < classArray.Length; i++)
{
CharClass class3 = classArray[i];
foreach (Character character2 in this.charSet)
{
if (character2.type == class3)
{
num21++;
int num23 = num21 % num15;
if (num23 == 0)
{
num23 = num15;
}
if ((num23 == 1) && (num21 > 1))
{
y += height + num13;
}
int x = ((width * (num23 - 1)) + num13) + num16;
if (character2.type == CharClass.Signature)
{
width *= 5;
}
Rectangle rect = new Rectangle(x, y, width, height);
graphics.FillRectangle(brush, rect);
graphics.DrawRectangle(pen, rect);
int num25 = (y + num4) + num10;
graphics.DrawLine(pen2, x, num25, x + width, num25);
graphics.DrawString(character2.representation, new Font("Microsoft Sans Serif", (float)num7), brush2, (float)(x + 3), (float)y);
int num26 = num25 + num9;
graphics.DrawLine(pen2, x, num26, x + width, num26);
graphics.DrawLine(pen3, x, num25 + (num9 / 2), x + width, num25 + (num9 / 2));
Graphics g = base.CreateGraphics();
Rectangle rectangle = rect;
rectangle.Y += num4;
rectangle.Height -= num4;
character2.setPosition(rectangle, num26, num25, g, this.inkOverlay.Renderer);
if (character2.type == CharClass.Signature)
{
width /= 5;
}
}
}
if (this.breakCharTypes || ((i < (classArray.Length - 1)) && (classArray[i + 1] == CharClass.Signature)))
{
y += height + num13;
num21 = 0;
}
}
this.picBoxCharacters.Image = image;
this.picBoxCharacters.Refresh();
}
public virtual Enumerator GetEnumerator()
{
return new Enumerator(this );///iam getting error on this line An unhandled exception of type 'System.StackOverflowException' occurred ()
}
iam using INKOVERLAY(Tablet PC using CSharp) class so that i can write under all the charcaters in the drawing area, my solution build successfully , no other errors but when the form load it show the stack overflow exeception , please help me out to solve the error
waiting for possitive response
with regards
radhika
|
|
|
|
|
Take a close look to your code:
Label_0104:
foreach (Character character in this.charSet){
foreach (CharClass class2 in classArray)
{
if (character.type == class2)
{
num17++;
goto Label_0104;
}
}
}
|
|
|
|
|