-
MaskedTextBox
Date: 11/18/05
Keywords: no keywords
Hi guys,
I am trying to make a text box that will allow users to enter values without having to stick to proper mask positions.
Say, I want them to enter a numeric value from 0 to 9,999,999.00 (culture specific). I add a mask "9,999,999.00".
So, if a user wants to enter "120" for $120, they will have to move to a proper mask position and then enter their values because the textbox will look like this: "_,___,___.00".
Is there a way for a blank text box that will just accept proper input chars?
Source: http://www.livejournal.com/community/csharp/41786.html
-
MaskedTextBox
Date: 11/18/05
Keywords: no keywords
Hi guys,
I am trying to make a text box that will allow users to enter values without having to stick to proper mask positions.
Say, I want them to enter a numeric value from 0 to 9,999,999.00 (culture specific). I add a mask "9,999,999.00".
So, if a user wants to enter "120" for $120, they will have to move to a proper mask position and then enter their values because the textbox will look like this: "_,___,___.00".
Is there a way for a blank text box that will just accept proper input chars?
Source: http://community.livejournal.com/csharp/41786.html
-
Of Character Encodings
Date: 11/18/05
Keywords: database, asp, sql, web
I am converting a web app from ASP to ASP.net and have stumbled on an annoying problem.
1. ASP code accepts user input and stores value in the database
SQL field type is nvarchar(200).
BUT the query does not use N'' to specify that the string is unicode.
2. Value stored in the database is '陳å°æ˜¥'
3. Value displayed on web page (utf8 encoding, no server side changes) is '陳小春'
4. Actual UTF data in the database is displayed on screen as ???
(database value: 人, display value: ?)
5. ASP.net application using the EXACT same queries results in point 4 being displayed correctly (as japanese) but the values that were displayed correctly in the ASP app are now exactly as they are in the database.
Please Help ... My only guess was that the ADO connection was converting the UTF in the database to Non-UTF for display in ASP and the ADO connection in .Net is preserving the Unicodeness of it.
But i did a simple test in ASP where i selected the data, stored it in a variable and then inserted back into the database (non using N'')
and well ... i got the exact same .... japanese was japanese the rest was garbage.
Anyone have any ideas???
Source: http://www.livejournal.com/community/csharp/41546.html
-
Of Character Encodings
Date: 11/18/05
Keywords: database, asp, sql, web
I am converting a web app from ASP to ASP.net and have stumbled on an annoying problem.
1. ASP code accepts user input and stores value in the database
SQL field type is nvarchar(200).
BUT the query does not use N'' to specify that the string is unicode.
2. Value stored in the database is '陳å°æ˜¥'
3. Value displayed on web page (utf8 encoding, no server side changes) is '陳小春'
4. Actual UTF data in the database is displayed on screen as ???
(database value: 人, display value: ?)
5. ASP.net application using the EXACT same queries results in point 4 being displayed correctly (as japanese) but the values that were displayed correctly in the ASP app are now exactly as they are in the database.
Please Help ... My only guess was that the ADO connection was converting the UTF in the database to Non-UTF for display in ASP and the ADO connection in .Net is preserving the Unicodeness of it.
But i did a simple test in ASP where i selected the data, stored it in a variable and then inserted back into the database (non using N'')
and well ... i got the exact same .... japanese was japanese the rest was garbage.
Anyone have any ideas???
Source: http://community.livejournal.com/csharp/41546.html
-
A system call that should never fail has failed.
Date: 11/10/05
Keywords: html, web
I'm writing a program that basically is supposed to go to a site that has a mailing list archive on it and download each message from the archive, month by month. I've got all the parsing stuff taken care of to where it's getting the correct links and downloading the correct messages, etc. I've also got it so that it'll download about 6 months of messages. After that, I get a socket exception with the message "A system call that should never fail has failed." Does anyone have any idea what could be causing this?
More details
I'm using the System.Net.WebClient class to get the content of the page. First I get the content of the index page and parse the relevant links out. Here's the index page, I'm grabbing the links that say "date."
After that, it goes into each month's archive and downloads all of the messages and writes them to a text file(after stripping out the html, etc.)
If I just do 5-7 months, they work just fine. After that, I get the following error with the following stacktrace:
Unable to read data from the transport connection: A system call that should never fail has failed. at System.Net.ConnectStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.IO.StreamReader.ReadBuffer()
at System.IO.StreamReader.ReadToEnd()
at MListGetter.Form1.getPage(String address) <==this method should download the message
at MListGetter.Form1.getMsgText(String url)
at MListGetter.Form1.processMonth(String dateline, String url)
at MListGetter.Form1.button1_Click(Object sender, EventArgs e)
Here is the text of the method where the exception is thrown:
private string getPage(string address)
{
System.Net.WebClient cl = new System.Net.WebClient();
System.IO.Stream s = cl.OpenRead(address);
System.IO.StreamReader sr = new System.IO.StreamReader(s);
string res = sr.ReadToEnd();
sr.Close();
s.Close();
cl.Dispose();
return res.Replace("\n", "\r\n");
}
I would be eternally grateful to anyone who can shed some light on this.
Source: http://www.livejournal.com/community/csharp/41360.html
-
A system call that should never fail has failed.
Date: 11/10/05
Keywords: html, web
I'm writing a program that basically is supposed to go to a site that has a mailing list archive on it and download each message from the archive, month by month. I've got all the parsing stuff taken care of to where it's getting the correct links and downloading the correct messages, etc. I've also got it so that it'll download about 6 months of messages. After that, I get a socket exception with the message "A system call that should never fail has failed." Does anyone have any idea what could be causing this?
More details
I'm using the System.Net.WebClient class to get the content of the page. First I get the content of the index page and parse the relevant links out. Here's the index page, I'm grabbing the links that say "date."
After that, it goes into each month's archive and downloads all of the messages and writes them to a text file(after stripping out the html, etc.)
If I just do 5-7 months, they work just fine. After that, I get the following error with the following stacktrace:
Unable to read data from the transport connection: A system call that should never fail has failed. at System.Net.ConnectStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.IO.StreamReader.ReadBuffer()
at System.IO.StreamReader.ReadToEnd()
at MListGetter.Form1.getPage(String address) <==this method should download the message
at MListGetter.Form1.getMsgText(String url)
at MListGetter.Form1.processMonth(String dateline, String url)
at MListGetter.Form1.button1_Click(Object sender, EventArgs e)
Here is the text of the method where the exception is thrown:
private string getPage(string address)
{
System.Net.WebClient cl = new System.Net.WebClient();
System.IO.Stream s = cl.OpenRead(address);
System.IO.StreamReader sr = new System.IO.StreamReader(s);
string res = sr.ReadToEnd();
sr.Close();
s.Close();
cl.Dispose();
return res.Replace("\n", "\r\n");
}
I would be eternally grateful to anyone who can shed some light on this.
Source: http://community.livejournal.com/csharp/41360.html
-
w00t!
Date: 11/10/05
Keywords: no keywords
*does the my-regular-expressions-work dance*
Source: http://www.livejournal.com/community/csharp/40785.html
-
Compiling & Batch files
Date: 11/08/05
Keywords: no keywords
I realize that this isn't quite a C# question, but I'm certain that some of you might have experience with a problem like this.
I'm writing some exercises in C# for a one of my classes. The problem is that we're restricted to using only the command line compiler. It was agreed that this was best, since we might not have the linsencing to afford VS.NET on the classroom machines.
Right now I have a batch file that invokes the compiler and, if successful, produces an exe. I'm honestly not all that familiar with DOS batchfiles (the classroom computers are Win2k), and it took me most of the afternoon to write the one I have.
Everything works fine up until I have to compile more than one file into an exe. I've hacked the batchfile to compile multiple source files by typing in each file name, but I was hoping for something simpler.
Is there any way to make the C# compiler "find" all the needed source files to compile an exe?
Source: http://www.livejournal.com/community/csharp/40524.html
-
VS 2005 released
Date: 10/30/05
Keywords: sql
MSDN subscribers had a notice last night when they logged in.
VS 2005 and the corresponding Sql Server 2005 and .Net 2.0 redist have been released.
Source: http://www.livejournal.com/community/csharp/40183.html
-
Need help with C# .NET and SQL Server with SJIS
Date: 10/26/05
Keywords: sql
I'm using SqlCommand and want to store SJIS encoded japanese into a table on SQLServer.
I get ?????? instead of the Japanese characters or the hex/binary. It's 3F3F3F3F and defaulted code for misunderstood characters. I need something that will preserve the code. I'm using NTEXT and stored procedure mode.
Any ideas/experience in this area?
Source: http://www.livejournal.com/community/csharp/39697.html
-
Programming Style
Date: 10/24/05
Keywords: no keywords
I've been writing a few small demonstration programs for a class the last week. As I've never really touched the language I've run across a few questions.
Could anyone point me to a good style guide for C#? I found this one, but I was looking for something a little more advanced.
For one, is it "proper" to create a class who's constructor can fail? Or is it better to create a separate init() function? Or a static factory method? The example code is going to given out to students, so I would like something clear and understandable.
Thanks!
Source: http://www.livejournal.com/community/csharp/39417.html
-
HttpSendRequest returns "internet name not resolved". HELP !
Date: 10/23/05
Keywords: microsoft
Hi ,
Sorry for double post ( cpp community) .
if anybody worked with wininet - you probably know what to do .
Help me, please !
I try to connect to the some server and to reseive some data .
All what I do - is standart windows HTTP commands (wininet .dll ):
1) internetOpen()
2)InternetConnect()
3)HttpOpenRequest()
4)HttpSendRequest()
HttpSendRequest function returns error "internet name not resolved" .
In is happens in case I connect to the internet InternetConnect() , and host name parametr
looks like name and not IP .
In case internet adress has look and feel of IP adress - HttpSendRequest ()
executes with NO error .
What can I do with that ? I MUST work with names !
Is it any way to convert the name to IP ?
HELP me , please.
P.S.
I work under
Microsoft eMbeded Visual c++
Source: http://www.livejournal.com/community/csharp/38961.html
-
Is there any LPT API?
Date: 10/13/05
Keywords: no keywords
Hello! help me please!!
I have device connected via LPT port
How can I control it's pins/stems? (I'm not really shure how to name it O_o )
First of all, I want to manage power supply
How can I do that?
Is there any LPT API?
Or I need to write the drivers?
I have special library, but it do works only under Win98 (not NT..XP)
Support me, please!! =))
Source: http://www.livejournal.com/community/csharp/38384.html
-
Loading assemblies
Date: 10/12/05
Keywords: no keywords
I'm sure I'm missing something simple here. I've created a dll containing a trivial c# class:
namespace Library
{
public class Foo
{
public static string Name()
{
return "Foo";
}
}
}
Now I'm trying to open it and find the class using reflection. Given that dir
is a System.IO.DirectoryInfo
with the directory listing in it, the code I'm using to open the dll (I've stripped out the error checking) is:
System.IO.FileInfo[] files = dir.GetFiles("*.dll");
foreach (System.IO.FileInfo fi in files)
{
string filename = fi.FullName;
System.Reflection.Assembly a = System.Reflection.Assembly.Load(filename);
// etc.
But the attempt to load the assembly gives:
System.IO.FileLoadException was unhandled
Message="The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)"
According to the help, that means that it could find the file, but it wasn't a valid assembly.
So what do I need to do to make it a valid assembly?
Source: http://www.livejournal.com/community/csharp/38098.html
-
Outgoing packets
Date: 10/07/05
Keywords: software, linux
Is there any way (besides using winpcap) to capture outgoing packets in Windows XP using C#.NET? I have written a neat socket class that binds to an interface and does a great job at throwing events for every packet received, but I don't see a single packet that's sent.
I have also downloaded several "example" applications from various .NET repositories on the internet that purport to capture outgoing packets, but don't.
I have heard of some issue (that may or may not be imagined) that outgoing packets capture using the stock network socket tools in Windows 2000 but not Windows XP. I don't know why this would be true, or even if it is true, but I do not have any software firewalls running on any of my PCs (I have a Linux machine acting as a combination firewall/router/PPPoE (*shudder*)/DHCP/etc. device, but that's my gateway and has nothing to do with the computers from which I am attempting to capture outgoing packets.
Any help, information, or source code is appreciated.
Source: http://www.livejournal.com/community/csharp/37744.html
-
when your exception handler throws an exception
Date: 10/06/05
Keywords: no keywords
What do you do when your exception handler throws an exception? For example say you have the following code:
try
{
//do something that's so impossibly cool, your head would explode if you saw it(hence, no code)
}
catch(Exception x)
{
Trace.Listeners.Add(new TextwriterTraceListener("log.txt", "LOG"));
Trace.WriteLine("oh NOES tEh expection! " + x.Message);
Trace.Listeners["LOG"].Close();
Trace.Listeners.Remove("LOG");
}
So say you catch an exception, but then your TextWriterTraceListener's underyling StreamWriter can't access log.txt, so it throws an IOException. Does your program just have to acknowledge that it's SOL and crash and burn? Is it Bad Design(TM) to do things this way? Will our heroes make it to the...oh wait, I got carried away with the questions there.
Source: http://www.livejournal.com/community/csharp/37248.html
-
Matrix Math Library
Date: 09/30/05
Keywords: no keywords
Can anyone suggest a C# lib for doing matrix math? Open source preferred, closed ok.
Source: http://www.livejournal.com/community/csharp/36727.html
-
XML part deux
Date: 09/26/05
Keywords: xml, web
Sorry to post another XML question so soon, but I promise this one's fundamentally different enough from the last one to merit a new post...
So I am creating an XML string in a class that gets bundled inside another XML string by another class before being sent to a WebService, where the reverse occurs (class members are populated by the XML string; a sort of deserialization, but not using the framework).
Let me first say that it works. One of the XML nodes contains an image encoded with base64, which is how I've been testing whether the XML is successfully built, parsed, transmitted, etc. I have a small client application that builds the XML and tests it by deserializing the image and displaying it; the server receives the XML, deserializes the image, and saves the image to the filesystem, where I can verify that it saves properly, displays properly, and all that jazz. So everything is working fine.
The trouble is that I've built into my WebService a functionality by which any string larger than a certain amount of bytes (currently 16k, but it can be changed) gets broken into chunks and sent one chunk at a time. The WebService reassembles the chunks, calculates the MD5 of the entire string, compares it to an MD5 of the string calculated by the client that the client sent prior to sending all these chunks, and if they match, commits the transaction into the session.
Let me also say that the above "chunking" process works on XML streams other than the one containing the image. For example, I tested it with a 1.7MB XML string that simply contained a bunch of ASCII nodes. The MD5s matched, I manually verified that the XML strings were identical on client and server, etc. So the source code is sound.
However, when I combine the above two particular processes -- the XML string containing an image in base64 and the "chunking" process -- a strange thing occurs. The MD5s no longer match after "chunking." Additionally, the lengths of the strings according to the client and the server after the string has been transmitted to the server differ by about 4k (the client says it's around 358k; the server says it's 354k). But when I ask the client and server each to write a text file of the XML, they both write out identical files that compare (using fc from the command prompt) with no differences found.
I'm officially stumped. Is it something having to do with base64? Is the base64 encoding getting conserved on the client side, but .NET's serialization is flattening it to ASCII for the server-side? Clearly such flattening doesn't matter, because the server can still put the image together without any errors. So if this is the problem, is there any way I can force this flattening to occur on the client-side prior to calculating an MD5 of the transmission?
I've tried forcing the XML through System.Text.Encoding.ASCII.GetBytes() and GetString() for kicks, but it didn't change the size nor the above problems.
If my theory is incorrect, please help me understand the problem and maybe what I could do to solve it given the above requirements.
Any help is appreciated!
Source: http://www.livejournal.com/community/csharp/36564.html
-
Text formatting and System.Xml
Date: 09/25/05
Keywords: xml
I am having a bit of a rough time with System.Xml, namely getting the XML that one of my classes generates to Load() back into an XmlDocument.
I am creating the XML with an XmlTextWriter using UTF-8 encoding. I write out the XML, obeying the spec to a fault. Everything is fine to this point.
Now, depending on how I load the XML back into a new XmlDocument, I get an error, or not. To wit:
Scenario 1: After I generate the XML, I write it straight to a text file using a StreamWriter (two lines: writer.Write(thisXML) and writer.Close()). Then, I make a new XmlDocument(), and call thisDoc.Load("myXMLFile.txt"). In this scenario, everything loads fine -- all of the document's children are available, and there are no exceptions.
The thing is, I'd like to avoid the whole writing to a text file bit, and keep it all in memory.
Scenario 2: After I generate the XML, I store it in a string. Then, I make a new XmlDocument(), and call thisDoc.LoadXml(myXMLString). In this scenario, on the line immediately following the LoadXml() method, I get a "System Error" exception from System.Xml. No other information from the exception.
I've put the contents of the XML string into a text box, and copied-pasted into several online XML schema checkers, and there are no errors. As a matter of fact, the EXACT SAME XML loads perfectly fine from a file.
I've also tried copying the string into a MemoryStream and calling thisDoc.Load(thisMemStream), figuring that maybe LoadXml() and Load() were different. Even using the memorystream, I get the same "System Error" exception.
What gives? Is it something with how UTF-8 is stored in a string vs. how it is stored in the file system? Is the file system doing something to the text representation that subsequently allows the System.Xml reader to successfully load the XML stream?
Argh. Any help appreciated.
Source: http://www.livejournal.com/community/csharp/36306.html
-
Forms Authentication problems
Date: 09/24/05
Keywords: database, asp, web
Hey all,
I've been running into a seriously weird problem of late... I have a Virtual Directory set up on my dev machine, on which I've developed my personal website. I have forms authentication and it's working fine. I come to deploy it under my pre-prod server (which is now a Website rather than a V. Dir.) and forms authentication gives me grief: once authenticated, it displays a blank page (correct address, but blank).
On the same machine, I stop the website and create a virtual directory, specifying the same location. Not a single file or permission changed. Bingo, lets me in. Anyone have any info on this?
Config: ASP.NET v 1.1, Forms Authentication done by a user control. No database, just DataSets running from .config files (I really don't foresee much traffic... Me, a couple of friends. I'm lucky if I get one hit a week outside of my own usage). Using a templating scheme as suggested by Joe Agster on devx here. My authentication code in a nutshell:
if (Authenticate(UserTextBox.Text, PassTextBox.Text))
{
FormsAuthentication.SetAuthCookie(UserTextBox.Text, PersistentCheck.Checked);
Response.Redirect(Request.ApplicationPath + "/default.aspx");
}
else
{
CommentLabel.Text = "Wrong credentials, please try again.";
CommentLabel.Visible = true;
}
Any idears?
Thanks in advance!
Source: http://www.livejournal.com/community/csharp/36027.html