home · blog · groups · about us · contact us
DevelopmentNow Blog
 Wednesday, October 26, 2005
 
 

Yes, free. Microsoft is doing a 200-city US tour over the next two months to promote Visual Studio 2005, SQL Server 2005, and BizTalk Server 2006. Not only is it an all-day event with speakers, classes, Q&A sessions, and more, but they're giving away a free copy of VS 2005 & SQL Server 2005 to all attendees (while supplies last). Best of all, it costs nothing to register.

So check out the Visual Studio 2005 Launch Tour site and register. And get free stuff. And then start developing -- believe me, the new tools are sweet.

October 26, 2005    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]



 Wednesday, October 19, 2005
 
 

It's often handy to have your web site or application send emails. "Thanks for registering." "Thanks for your order." "Hey tech support, the web site is down."

.NET 2.0 provides a few handy classes for outbound emails. Below is some code you can use in your ASP.NET application to send an email. Notice there is some authentication code you can use if your SMTP server requires a username and password in order to send emails. If you aren't sure, try sending an email without a username or password. If you get an SmtpException with a 550 or 553 Relay denied error (SmtpException.StatusCode == SmtpStatusCode.ClientNotPermitted), then you'll need to authenticate. :)

// create the message object
System.Net.Mail.MailMessage myMessage = new System.Net.Mail.MailMessage();

myMessage.To[0] = "some.guy@hotmail.com";
myMessage.From = "some.girl@hotmail.com";
myMessage.Subject = "this is a test message";
myMessage.Body = "hello there!\ntest message!";

// create the SmtpClient object. Specify the SMTP server in the Host property
System.Net.Mail.SmtpClient mySMTPClient = new System.Net.Mail.SmtpClient();
mySMTPClient.Host = "smtpserver.emailfarm.com";

if (SMTP_SERVER_REQUIRES_AUTHENTICATION)
{
	// create the NetworkCredential object with the username & password 
	// to authenticate against the SMTP server
	System.Net.NetworkCredential myCredentials = 
		new System.Net.NetworkCredential("username", "password");
	mySMTPClient.UseDefaultCredentials = false;
	mySMTPClient.Credentials = myCredentials;
}

// send the message
try
{
	mySMTPClient.Send(myMessage);
}
catch (SmtpException e)
{
	Response.Write(e.StatusCode);
}

If you feel the need to email a file to someone, use code like the below

// Attach a file to the email message. 
// The second parameter is the content type (text, binary file, etc.)
System.Net.Mail.Attachment myAttachment = new Attachment(strFilename, MediaTypeNames.Text.Plain);
myMessage.Attachments.Add(myAttachment);

Lastly, you can send an email asynchronously via the SmtpClient.SendAsync(MailMessage, CallbackToken) method. You can attach an event handler to the SmtpClient.SendCompleted event to receive notification when your email has been sent. One big downer is you can only send one asynchronous email at a time -- if you're currently waiting for a previous SendAsync call to finish, other Send or SendAsync calls will fail. Which sortof sucks.

// Send an email without waiting for completion
mySMTPClient.SendCompleted += new SendCompletedEventHandler(MyHandler);
mySMTPClient.SendAsync(myMessage, null);

void MyHandler(System.Object sender, AsyncCompletedEventArgs e)
{
	// code goes here to say "sending complete!" or something
}

Related links:
SmtpClient: http://msdn2.microsoft.com/en-us/library/4971yhhc(en-US,VS.80).aspx
SendAsync: http://msdn2.microsoft.com/en-us/library/x5x13z6h(en-US,VS.80).aspx
Attachment: http://msdn2.microsoft.com/en-us/library/e02kz1ak(en-US,VS.80).aspx

 

October 19, 2005    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]



 Tuesday, October 11, 2005
 
 

The upcoming MSDN offerings will provide copies of Microsoft's latest and greatest, including Visual Studio 2005, Windows Vista, Team System, et al. Unfortunately, the highest-level MSDN package is $10,000 (pricing chart). Which is huge. Huge enough to make development shops look at Subversion (instead of VSS) and other alternatives. Especially when you consider that if you have a QA department, all your testers need an MSDN license in order to test software built using MSDN-licensed tools (oh yes, it's true).

One big way to get that software but save on licenses is to enroll in the Empower ISV program. For $375/year, you get 5 MSDN Universal licenses, plus a bunch of other stuff. The downside (?) is you have to actually build something using Microsoft tools, and the license is only good for a year. And you also have to take a stab at getting some people MS-certified.

October 11, 2005    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]



 
 

If you have a 32 bit application uses custom registry values (e.g. HKLM/Software/MyApp/MySetting), it might have problems accessing those keys when run on 64-bit Windows. That's because 64-bit Windows (via WOW64, the 32-bit emulator that runs on 64-bit Windows) has separate sections in the registry for 32-bit apps and 64-bit apps. So when run on 64-bit windows, if a 32-bit app is looking for

HKLM/Software/MyApp/MySetting

it actually needs to look in

HKLM/Software/WOW6432Node/MyApp/MySetting

when running on 64-bit Windows.

If you want to use the same key location regardless of which OS you're running, you need to enable registry reflection (or registry mirroring) for the keys you're interested in. WOW64 uses registry reflection to store certain keys in both the 32-bit and 64-bit registry sections. This allows 32-bit and 64-bit applications to share the same set of registry keys, and allows your application to use the same key on 32-bit and 64-bit Windows. A number of keys are reflected by default (e.g. HKLM/Software/Classes, a bunch of stuff under HKLM/Software/Microsoft), but you can use the RegEnableReflectionKey function to ask the OS to provide reflection for any key you need shared between 32-bit & 64-bit code (for example, our friend HKLM/Software/MyApp/MySetting).

More info:

http://support.microsoft.com/?kbid=305097

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/win64/win64/registry_reflection.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/win64/win64/running_32_bit_applications.asp

 

 

OS
October 11, 2005    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]



 Tuesday, August 30, 2005
 
 
If you use Remote Desktop (aka Terminal Services) to connect to Windows servers, you probably know that by default ony two people can be connected via RDC at a time. So it sucks when you need to get onto a machine but you get the dreaded messages:

The terminal server has exceeded the maximum number of connections

or

The system can not log you on. The system has reached its licensed logon limit.

Especially when it's late at night and no one else is in the office. :) So, there are two solutions to get you past the blockade:
  1. Log onto a different server (one with free RDC connections) on the same network and domain as the blocked server. Open up Terminal Services Manager, navigate to the blocked server, open up the list of connected users, right-click a victim (preferably a long-idle one) and Log Out and Disconnect them. Wait up to 30 seconds, and they should drop off. Now you can connect to that server and fix that bug you accidentally migrated. :)
  2. If the above solution doesn't work, you can actually RDC to the console session (i.e. as if you were sitting at the PC's keyboard), which can act as a third RDC connection independent of the two main RDC connections. To do this:
    • Open on a command prompt (Start->Run->"cmd").
    • Enter "mstsc /v:<servername> /console" and hit Enter. <servername> should be replaced by the machine name of the server you're connecting to.
    • You should see a familiar RDC console window come up & be able to log in. Note that if someone else is logged in at the console, either
      • If you're an Administrator, you'll have the opportunity to kick them off.
      • If you're not an Administrator, you're out of luck on the console session. But at least you tried.
Hopefully the above will help provide a workaround for the 2-connection RDC limit on busy boxes.


OS
August 30, 2005    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]



 Monday, August 08, 2005
 
 
SADeveloper has an interesting article on programmer productivity, basically along the lines that a good programmer can be 5-20 times as productive as a poor one. My first boss drilled into me that "software development was one of the few professions where a one person can be ten times as productive as another." And I believe it -- poor programmers can screw up code, get stuck constantly, miss requirements and have to re-work things, deliver bug-ridden code, etc. Other "creative" professions (science, music, etc.) are similar in that the productivity gap can be surprising.

Ray from CodeBetter had some interesting counterpoints to the article, but I've seen firsthand how much poor developers can stink. If you remove all thinking from the task, then the only measurement you'd need was typing speed & mouse-hand speed. But that's not what defines the productivity of a developer -- it's what their brain does that makes the difference.

Now, the funny part is I think with proper training, a good architect, smart division of labor, & in-place processes, you can narrow the productivity gap. Someone who sucks should be moved or fired. And in a gunslinger code culture, your rock stars will always smoke the average Joes. But what if you instead have
  • training so that everyone knows the project process
  • an actual project process that minimizes problems of scope creep, requirements confusion, and implementation/architecture snafus. RUP comes to mind, but there are others (MSF, XP, etc.).
  • dedicated people for the tasks that "poor/average" programmers often mess up on (architecture, project planning, requirements, etc.)
  • a software architect who can divide tasks among developers according to their skill level
  • a culture that encourages learning and asking questions
  • a good screening system to get rid of or avoid hiring people who don't work well in teams
  • a mentoring system to pass along tips and information
With the above, I think you can reduce the productivity gap. You eliminate or reduce many of the issues that cause weaker developers to fall so far behind their counterparts. You'll still have faster and slower programmers, people who can devise algorithms or who know their APIs and patterns backwards and forwards instead of having to Google them all the time. But time and again, some of the biggest sandtraps I've seen programmers fall into are ones related to architecture, project management, and failure to follow a methodology and process that guides people towards better applications.
August 8, 2005    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]



 Thursday, August 04, 2005
 
 
Bah, got some blog comment spam the other day. Or at least I think it was spam. Even though dasBlog has a CAPTCHA control on the comment field (to prevent most comment-spam-bots), people can still manually add comments that have no relevance & link to their sites filled with affiliate links. Bujarf.
August 4, 2005    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]



 Monday, August 01, 2005
 
 

Found a great writeup on abstract classes versus interfaces at the code project. While not every developer or project makes use of those OOP constructs, it's important to be familiar with OOP terms for a few reasons:

  • So you can design better systems
  • So you can expand your knowledge
  • So you can better understand other developers' code
  • So you don't look like a n00b at some developer gathering

I feel that developers using Microsoft platforms are sometimes at a disadvantage when it comes to practical experience with OOP concepts. Not all developers, but if people started out coding in ASP or VB, they may not have the years of OO development that someone starting with java/etc would. I place the blame solely on the earlier MS platform and the "build it quick & dirty" ability that RAD toolkits accommodated. I'm not bashing anyone...there are many great coders on all platforms. But do you know how kludgey it was doing OO with VB6, ASP 3? Yup...pretty goofy.

Anyhow, I like simple straightforward writeups that I can print out & read on the train, etc. Hence the above link. Plus a link to CodeBetter's Feb 2005 articles -- there are some articles in there on OO concepts (abstraction, encapsulation, inheritance, and polymorphism) that will help any budding OO buddy.

August 1, 2005    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]



 Monday, July 25, 2005
 
 

My Yahoo referrals went WAY down last week, and I realized that dasBlog doesn't direct-link to URLs in posts. Which normally is good. However, it means that when I linked to all my old blog content, spiders weren't able to see it. So Yahoo thinks all my blog posts went away, and so I have less content, and so I'm not worth sending traffic to as much. Which is a downer.

So for now the archive links are in the blogroll, which is a direct link. Eventually I'll rework the site design.

July 25, 2005    Bookmark to Digg or other social bookmarking
#    Disclaimer  |  Comments [0]