|
-
String[] / ArrayList Problems
Date: 01/19/05
Keywords: no keywords
I've written a class that queries game servers on the on the Quake3 network type, and I've come into a small problem. After you send the status packet to the server, it responds back with one packet, with each part being separated by a line break. (Line 1 = useless start, Line 2 = Server Info, Line 3 = Playerinfo.) After I split it, (using '\n') I can easily access each part, but not in the way I need to. All I need to do is add _Response[1] to the arraylist, but I get an error... heres what I tried.
string[] _newResponse = _Response.Spilt('\n');
Console.WriteLine(_newResponse[0]); // Outputs the useless packet start Console.WriteLine(_newResponse[1]); // Outputs all server info Console.WriteLine(_newResponse[2]); // Outputs all player info
foreach(string Val in _newResponse[1]) // ERROR: Cannot convert type 'char' to 'string' { ServerVars.Add(Val); }
Any ideas? Thanks.
Source: http://www.livejournal.com/community/csharp/23194.html
-
C# and SOAP serialization
Date: 12/27/04
Keywords: xml
Hello, everyone. I have a question regarding SOAP serialization. As far as I know, SOAP specification allows arbitrary XML constructs to be appear in the body of SOAP message in a way similar to this:
My program manages RDF/OWL (RDF and OWL are subsets of XML with defined schema) descriptions. It parses RDF/OWL files, creates some objects, transmits them using SOAP, and then creates RDF/OWL files again from the objects recieved on the endpoint, so newly created files could be used by any application that conforms RDF/OWL specification.
The problem is that I want to define custom SOAP serialization using SoapFormatter. I need to set up serialization in a way it allows me to create arbitrary XML in messages. Working with basic attributes controlling SOAP serialization didn't help at all -- SoapFormatter ignores them.
Using XmlSerializer is not the right way, I think. Moreover, creating complex SOAP messages with collections could be nontrivial task (we have to manage all the 'refs' in SOAP message and so on), so it won't help.
So I need ANY advice on how to create arbitrary XML elements in SOAP messages. Thanks in advance.
Source: http://www.livejournal.com/community/csharp/22848.html
-
simple XML library
Date: 12/21/04
Keywords: xml
Does anybody know of a good, simple XML library? I'm looking for something that can parse an XML tree and return some kind of data structure that reflects the contents.
Such functionality may be built-in, but I can't find it if so. Any help would be appreciated :)
Update: I need to do it at runtime, as the tree I'm parsing is the return value from a network operation :/ It also needs to run under Mono, so anything that uses (for instance) XPath is out.
Source: http://www.livejournal.com/community/csharp/22654.html
-
Minimizing .net Framework memory occupation...?
Date: 12/17/04
Keywords: no keywords
Hello all,
Ok, I have a silly question but I can't help but ask it: all my .Net apps take up a significant amount of RAM (17 megs for c++ win app, 18 for c# win app, 9ish for console apps). The problem is that the .Net framework is simply HUGE. And now, here's the two part question:
1) Is there a way to "shrink" the framework so that it uses the bare minimum (though I get the feeling that apart from removing as many ref's as humanly possible, that's about as small as it can get)
2) Any way of running the .Net *compact* framework on a regular machine without using the humongous emulator?
Source: http://www.livejournal.com/community/csharp/22447.html
-
The Nex Web Browser
Date: 12/02/04
Keywords: browser, xml, technology, web
Hello! I had release my Nex Web Browser version A1 at http://nex.sourceforge.net/ . Now I preparing the A2 version for releasing, and this will be very interest to read your opinions about this program, its Internal Protocol (NIP, provides LDP - Local Dynamic Page) technology, XML configuration format, LanguageSet implementation, sidebar, etc..
Source: http://www.livejournal.com/community/csharp/21817.html
-
Form validation using regular expressions
Date: 11/20/04
Keywords: no keywords
Hi, I want to validate the string for the "First Name" field in a windows application. Here's the code I wrote,
public static bool firstname(TextBox box) { bool correct = true; if ( !Regex.Match( box.Text, @"^[A-Z]+([a-zA-Z]+|[a-zA-Z]+\s[a-zA-Z]+)*$" ).Success ) { correct = false; } else correct = true; updateControlColor(box, correct); return correct; }
Everything works, except it doesn't allow "-" (hyphens) in the field. What's the correct way to write the regex? (and hyphens can only follow a word, not the whitespace).
Also, I am binding an ErrorProvider object to the form, how can I display the error message onto the windows application? (Right now, the error message only shows up when I mouse-over the error icon).
Thanks in advance.
Source: http://www.livejournal.com/community/csharp/21648.html
-
... System.Xml
Date: 11/10/04
Keywords: xml, microsoft
Ive been grinding my teeth on this one for the past hour. Even taking cuts from MS code and others i get the same results.
using System;
namespace TocGen { /// /// Summary description for Stringys. /// public class Stringys { public enum OOOXMLType { content, meta, settings, styles, }
#region Helpers /// /// Writes a FULL attribute to a tag on an XML Text Writer /// /// Supplied Writer /// Attribute Prefix /// Attribute Name /// Attribute Namespace /// Attribute Value public static void WriteFullAttribute(System.Xml.XmlTextWriter oXw, string pre, string n, string ns, string val) { oXw.WriteStartAttribute(pre,n,ns); if (val!=null) oXw.WriteString(val); oXw.WriteEndAttribute(); } #endregion public static void StartXMLDocument(OOOXMLType Dt, System.Xml.XmlTextWriter oXw) { // Enable Dreamweaver Styled Formatting oXw.Indentation=2; oXw.IndentChar=Char.Parse(" "); oXw.Formatting=System.Xml.Formatting.Indented; // oXw.WriteStartDocument(); switch (Dt) { case OOOXMLType.content: // oXw.WriteDocType("office:document-content","-//OpenOffice.org//DTD OfficeDocument 1.0//EN","office.dtd",null);
// // xmlns:text="http://openoffice.org/2000/text" xmlns:table="http://openoffice.org/2000/table" xmlns:draw="http://openoffice.org/2000/drawing" // xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:number="http://openoffice.org/2000/datastyle" // xmlns:svg="http://www.w3.org/2000/svg" xmlns:chart="http://openoffice.org/2000/chart" xmlns:dr3d="http://openoffice.org/2000/dr3d" // xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="http://openoffice.org/2000/form" xmlns:script="http://openoffice.org/2000/script" // office:class="text" office:version="1.0"> oXw.WriteStartElement("office", "document-settings", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", null, "http://openoffice.org/2000/office", null); //ERROR ALLWAYS HAPPENS HERE TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "style", "http://openoffice.org/2000/style", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "text", "http://openoffice.org/2000/text", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "table", "http://openoffice.org/2000/table", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "draw", "http://openoffice.org/2000/drawing", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "fo", "http://www.w3.org/1999/XSL/Format", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "xlink", "http://www.w3.org/1999/xlink", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "number", "http://openoffice.org/2000/datastyle", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "svg", "http://www.w3.org/2000/svg", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "chart", "http://openoffice.org/2000/chart", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "dr3d", "http://openoffice.org/2000/dr3d", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "math", "http://www.w3.org/1998/Math/MathML", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "form", "http://openoffice.org/2000/form", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "script", "http://openoffice.org/2000/script", null); TocGen.Stringys.WriteFullAttribute(oXw, "office", "class", null, "text"); TocGen.Stringys.WriteFullAttribute(oXw, "office", "version", null, "1.0"); oXw.WriteEndElement();
break;
case OOOXMLType.meta: // oXw.WriteDocType("office:document-meta","-//OpenOffice.org//DTD OfficeDocument 1.0//EN","office.dtd",null);
// // xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="http://openoffice.org/2000/meta" office:version="1.0"> oXw.WriteStartElement("office", "document-settings", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "office", "http://openoffice.org/2000/office", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "xlink", "http://www.w3.org/1999/xlink", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "dc", "http://purl.org/dc/elements/1.1/", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "meta", "http://openoffice.org/2000/meta", null); TocGen.Stringys.WriteFullAttribute(oXw, "office", "version", null, "1.0"); oXw.WriteEndElement();
break;
case OOOXMLType.settings: // oXw.WriteDocType("office:document-settings","-//OpenOffice.org//DTD OfficeDocument 1.0//EN","office.dtd",null); // // xmlns:config="http://openoffice.org/2001/config" office:version="1.0"> oXw.WriteStartElement("office", "document-settings", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "office", "http://openoffice.org/2000/office", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "xlink", "http://www.w3.org/1999/xlink", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "config", "http://openoffice.org/2001/config", null); TocGen.Stringys.WriteFullAttribute(oXw, "office", "version", null, "1.0"); oXw.WriteEndElement();
break;
case OOOXMLType.styles: // oXw.WriteDocType("office:document-styles","-//OpenOffice.org//DTD OfficeDocument 1.0//EN","office.dtd",null);
// // xmlns:text="http://openoffice.org/2000/text" xmlns:table="http://openoffice.org/2000/table" xmlns:draw="http://openoffice.org/2000/drawing" // xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:number="http://openoffice.org/2000/datastyle" // xmlns:svg="http://www.w3.org/2000/svg" xmlns:chart="http://openoffice.org/2000/chart" xmlns:dr3d="http://openoffice.org/2000/dr3d" // xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="http://openoffice.org/2000/form" xmlns:script="http://openoffice.org/2000/script" // office:version="1.0"> oXw.WriteStartElement("office", "document-settings", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "office", "http://openoffice.org/2000/office", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "style", "http://openoffice.org/2000/style", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "text", "http://openoffice.org/2000/text", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "table", "http://openoffice.org/2000/table", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "draw", "http://openoffice.org/2000/drawing", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "fo", "http://www.w3.org/1999/XSL/Format", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "xlink", "http://www.w3.org/1999/xlink", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "number", "http://openoffice.org/2000/datastyle", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "svg", "http://www.w3.org/2000/svg", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "chart", "http://openoffice.org/2000/chart", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "dr3d", "http://openoffice.org/2000/dr3d", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "math", "http://www.w3.org/1998/Math/MathML", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "form", "http://openoffice.org/2000/form", null); TocGen.Stringys.WriteFullAttribute(oXw, "xmlns", "script", "http://openoffice.org/2000/script", null); TocGen.Stringys.WriteFullAttribute(oXw, "office", "version", null, "1.0"); oXw.WriteEndElement();
break;
default: throw new System.NotSupportedException(); } oXw.Flush(); //oMs.Position = 0; //System.IO.StreamReader oSr = new System.IO.StreamReader(oMs); //#if (DEBUG) //System.Windows.Forms.MessageBox.Show(oSr.ReadToEnd()); //#endif } } }
I allways receive the following error: An unhandled exception of type 'System.ArgumentException' occurred in system.xml.dll Additional information: An undefined prefix is in use.'DefaultDomain': Loaded 'c:\windows\microsoft.net\framework\v1.1.4322\mscorlib.dll', No symbols loaded. 'TocGen': Loaded 'C:\Documents and Settings\Glenn\My Documents\Visual Studio Projects\WhelenOOO\TocGen\bin\Debug\TocGen.exe', Symbols loaded. 'TocGen.exe': Loaded 'c:\windows\assembly\gac\system.windows.forms\1.0.5000.0__b77a5c561934e089\system.windows.forms.dll', No symbols loaded. 'TocGen.exe': Loaded 'c:\windows\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll', No symbols loaded. 'TocGen.exe': Loaded 'c:\windows\assembly\gac\system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll', No symbols loaded. 'TocGen.exe': Loaded 'c:\windows\assembly\gac\system.xml\1.0.5000.0__b77a5c561934e089\system.xml.dll', No symbols loaded. An unhandled exception of type 'System.ArgumentException' occurred in system.xml.dll
Additional information: An undefined prefix is in use.
Any idea at all why? Ive searched MSDN and several other sites... No dice. Any help would be appreciated.
Source: http://www.livejournal.com/community/csharp/21413.html
-
Heh
Date: 11/04/04
Keywords: no keywords
Geek Humor
VB.NYET
:)
Source: http://www.livejournal.com/community/csharp/21048.html
-
simple question
Date: 11/03/04
Keywords: google
I'm new to c# and am having a hard time figuring out how to round a string which contains a number like 123.4567 to two decimal places. Google isn't helping much :(
Source: http://www.livejournal.com/community/csharp/20871.html
-
This is what is wrong with AssemblyInfo.cs
Date: 11/02/04
Keywords: templates, security, microsoft, google
// Assembly someassembly, Version 1.0.1692.12511
[assembly: AssemblyVersion("1.0.1692.12511")]
[assembly: AssemblyKeyName("")]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("")]
Almost every assembly that isn't coming from Microsoft looks like the above. While assembles from Microsoft look like:
// Assembly System.ServiceProcess, Version 1.0.5000.0
[assembly: AssemblyVersion("1.0.5000.0")]
[assembly: AssemblyDescription("System.ServiceProcess.dll")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyDefaultAlias("System.ServiceProcess.dll")]
[assembly: AssemblyKeyFile(@"E:\DNA\public\tools\common\security\FinalPublicKey.snk")]
[assembly: AssemblyDelaySign(true)]
[assembly: AssemblyConfiguration("Microsoft .NET Framework build environement is Retail.
SafeSync counter=0")]
[assembly: AssemblyTitle("System.ServiceProcess.dll")]
[assembly: ComVisible(false)]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SatelliteContractVersion("1.0.5000.0")]
[assembly: AssemblyInformationalVersion("1.1.4322.2032")]
[assembly: AssemblyTrademark("Microsoft and Windows are either registered trademarks or
trademarks of Microsoft Corporation in the U.S. and/or other countries.")]
[assembly: AssemblyCopyright("Copyright (C) Microsoft Corporation 1998-2002. All rights
reserved.")]
[assembly: AssemblyProduct("Microsoft (R) .NET Framework")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification=true)]
This is just my pet peeve of the moment inre Microsoft tools and project defaults. Why must it be so hard to build your own project templates? It just makes no sense to me. Heck in the beat of 2005 they move the AssemblyInfo.cs file even further from developer eyes.
[UPDATE]- A general Google search which will return lots of empty AssemblyInfo.cs files
- And very little guidance from Microsoft in a site limited Google search.
- An example of a good AssemblyInfo.cs file from a blog.
Source: http://www.livejournal.com/community/csharp/20491.html
-
MissingMethodException
Date: 11/02/04
Keywords: no keywords
Dear experts :),
I have recently started to learn my first steps in C#. I am already an experienced programmer, but C# is new to me.
What I've done is this: - I've created a class library that I called "DAWG". Its intended purpose is not important here.
- This library has a class, Wordlist, which has a constructor that doesn't do anything other than setting a member variable to null.
- The main program consists of little else than a form with a menu with two menu items: Open and Exit. Open is supposed to open a word list and create a DAWG from it.
The problem is that I get a MissingMethodException whenever the code for the form contains the line wordlist = new Wordlist(); . If I put that line in the constructor of the form, I get the exception immediately when starting the program. If I put it into the method that is linked to the 'Open' menu item, I get it when I click the menu item. In both cases, however, the exception occurs in "Non-user code", according to the call stack; it does not seem to occur when the Wordlist constructor is actually called.
In case it is important, I should also mention that the application is targeting the Pocket PC platform, but I don't think this would matter.
Thanks for any help you can offer!
Source: http://www.livejournal.com/community/csharp/20245.html
-
ado.net for bulk data transfer
Date: 10/28/04
Keywords: database, web
hi all
i have a webservice that returns multiple datasets of different tables that i need to merge/sync with a destination database that is accessible through a middle tier component that i wrote. unfortunately, i'm restricted to the use of ado.net and datasets due to the nature of the webservice in question. i'm working with moderately high number of records (largest table is around 5k rows) that i need to insert into the destination database, and i'm using the dataset.merge method with a customized insertcommand (as i need to wrap identity insert on around it and also the table columns won't be determined till run time) passed to the dataset, and it's pretty slow. i think part of the slowness comes from having to figure out the column schema of the varying tables, and also the fact that ado.net is not particularly a useful tool for data transfer. just wanted to know if anyone has any pointers/ideas as to how to optimize this routine? thanks in advance for your input.
Source: http://www.livejournal.com/community/csharp/19919.html
-
Interfaces
Date: 10/25/04
Keywords: programming
For the longest time, I just plain haven't understood what interfaces were about. Today I decided it was high time to find out. I found two links that finally got it through my thick head:
Working with Interfaces in C#
A Twisted look at Object Oriented Programming in C# - Interfaces
Recommended reading for the curious.
Lerch, now off to implement IEnumerable interface in one of his business layer objects.
Source: http://www.livejournal.com/community/csharp/19550.html
|