This is a dumping ground of software development topics that I've run across and found interesting (mainly .NET development). Many topics are covered more thoroughly in other places, and much of the information is gleaned from other places, and I'll try to credit those sources when possible.
Thursday, April 05, 2007
Windows Firewall for FTP
This is silly, but it hung me up for more than a few minutes. I was trying to FTP from a laptop to my desktop PC (running Microsoft's IIS FTP server). The client would claim it was connected, then after a few seconds, report "Connection closed by remote host." So I'm guessing it's a firewall problem, and I'm right (for a change), but it was still not easy to find. So below are the screen shots of the magical checkbox I needed to check.
Thursday, February 01, 2007
Random Password Generator
I needed to create a random password. First I found this short method, which didn't work. Then I found this guy agreed with me. His code works, but not so hot in my test program. The parameterless Random constructor uses a time-based seed value (per millisecond?) so there are duplicates. The code I ended up with reuses a single Random member.
Then there's the holy grail, which was too much for the requirements I was working with, eight alphanumeric digits only. Simplicity is divine.
Then there's the holy grail, which was too much for the requirements I was working with, eight alphanumeric digits only. Simplicity is divine.
private Random m_random = new Random();
public string CreateRandomPassword(int length)
{
char[] chars = new char[length];
int index = 0;
while (index < length)
{
char c = (char)m_random.Next(48, 122);
if (Char.IsLetterOrDigit(c))
{
chars[index] = c;
index++;
}
}
return new string(chars);
}
Thursday, December 14, 2006
C# vs. Java
Here is an interesting comparison of C# and Java. I like the way the sections are organized by:
- Same functionality.
- Similar functionality.
- Same concept, but totally different implementation.
- Unique C# functionality
- Unique Java functionality
http://www.25hoursaday.com/CsharpVsJava.html
- Same functionality.
- Similar functionality.
- Same concept, but totally different implementation.
- Unique C# functionality
- Unique Java functionality
http://www.25hoursaday.com/CsharpVsJava.html
Wednesday, November 29, 2006
Installing IIS after Visual Studio
This is pretty lame, but it's bit me twice causing a few wasted hours. If you install IIS after Visual Studio, some ASP.NET settings aren't applied properly. After messing with permissions and other settings to no avail, I did a Repair of the .NET Framework installation and I was in business. The Microsoft article below doesn't mention the Repair, but says to use the aspnet_regiis utility. Maybe I'll try that next time...
http://support.microsoft.com/default.aspx?scid=kb;en-us;306005
http://support.microsoft.com/default.aspx?scid=kb;en-us;306005
Ping memory leak?
The details give me a headache, but there appears to be a leak in the 2.0 Ping class, particularily when sending asynchronously.
http://blog.downtownsoftwarehouse.com/2006/11/14/using-the-ping-class-in-net-20-without-memory-leaks/
A longer diatribe that reaches the same conclusion:
http://www.julmar.com/blog/mark/PermaLink,guid,fc83197b-ce2d-47ab-b70a-db352085b370.aspx
And just in case the links above die, here's the gist of it:
"...you must explicitly call IDisposable.Dispose(), or you’ll end up with the inherited Dispose() method which doesn’t do anything useful at all in this case. You can do this by casting the Ping object to IDisposable."
http://blog.downtownsoftwarehouse.com/2006/11/14/using-the-ping-class-in-net-20-without-memory-leaks/
A longer diatribe that reaches the same conclusion:
http://www.julmar.com/blog/mark/PermaLink,guid,fc83197b-ce2d-47ab-b70a-db352085b370.aspx
And just in case the links above die, here's the gist of it:
"...you must explicitly call IDisposable.Dispose(), or you’ll end up with the inherited Dispose() method which doesn’t do anything useful at all in this case. You can do this by casting the Ping object to IDisposable."
private void Refresh(Object sender, EventArgs args)
{
Ping ping = null;
try
{
ping = new Ping();
ping.PingCompleted += PingComplete;
ping.SendAsync(defaultHost, null);
}
catch
{
((IDisposable)ping).Dispose();
}
}
private void PingComplete(Object sender, PingCompletedEventArgs args)
{
((IDisposable)sender).Dispose();
}
Friday, October 20, 2006
What the...
Your mother might not find it interesting, but if you're reading this, then I bet you'll find http://thedailywtf.com quite enjoyable. It's good to hear of situations worse than your own. And if yours is worse, then submit it and we can all laugh with you.
C# .NET Click vs. DoubleClick
This is kind of silly, but slightly interesting nonetheless. I needed to create a backdoor into a WinForm app, so I chose a lucky Label to be the gatekeeper. Ten clicks on the Label control and then enter the secret password to get in. Sounds simple enough, but adding a handler for the Label's Click event didn't quite work. I'm a notorious fast clicker, and it turns out many of my clicks were actually interpretted as double clicks. So if I clicked slowly ten times, it would work. That's the long story, the short story is, I used the MouseDown event instead.
Subscribe to:
Posts (Atom)
Followers
Blog Archive
Interesting Links
About Me
- Ryan McFarren
- woot woot!