March 4, 2009

Handling Null Session and Request Variables

In ASP.NET, if you try to use a session or request variable before it has been set, you’ll get an error. The following functions prevent this by checking for nothing and returning a null string if this is true. Public Shared Function zGetSessionValue(ByVal se As HttpSessionState, ByVal keyItem As String)

Building Domain Specific Languages in C#

t the JAOO conference in Aarhus, Denmark this year, domain specific languages came up in virtually every conversation; every keynote mentioned them, a lot of sessions discussed them (including a pre-conference workshop by Martin Fowler and myself), and you could hear “DSL” in most of the hallway conversations. Why this,

Create a New Event Using AWTEventMulticaster

This code shows how to create a new event using AWTEventMulticaster. import java.awt.*;import java .awt.event.*;class Buton extends Component{ private Image button_pressed,button_released; private boolean press=false; ActionListener actionListener; public Buton(){ button_pressed=Toolkit.getDefaultToolkit().getImage(“?”); //pressed button button_released=Toolkit.getDefaultToolkit().getImage(“?”); //released button MediaTracker mt = new MediaTracker(this); mt.addImage(button_pressed,0);mt.addImage(button_released,1); try { mt.waitForAll(); } catch (InterruptedException e) {System.out.println(e.getMessage()); } enableEvents(

Obtain the Local Absolute Path of a Class File

This tip shows how to obtain the local absolute path of a class file containing the specified class name, as prescribed by the current classpath. Call this method as you would FilePath.getFilePath(“packagename.classname”). This returns the absolute file path of the class: import;public class FilePath { public static String getFilePath(String

WCF and MSMQ—Take a Message

he inherent advantages to introducing queues into an application architecture are well understood. Queues, when used properly, can: Increase application robustness, as clients can send messages even when services are not running. Increase application scalability, because multiple service instances can be used to process messages from a single queue. Improve