Label Cloud

Tuesday, November 21, 2006

Using the SQL Server Hosting Toolkit

I've been developing SQL Server based project in the office and on my laptop. Synchronizing the database changes both schema and data is complicated and I was looking for good tool to help with it. Well, now there is one.

Microsoft released a 2nd CTP of SQL Server Hosting Toolkit. Its soul purpose is to create a script to recreate schema and data of a SQL serve database. All it takes is two clicks using the wizard.


Thursday, November 16, 2006

WCF - Processing untyped messages from MSMQ binding

Now that .NET 3.0 is finally released, I am putting in some hours to see how it can be implemented in our infrastructure. Up front the power and flexibility of the framework is a bit overwhelming, however, the tools that are included are great. For example Service Configuration Editor has a great way to specify every setting required and optional for setting up WCF communication.

One of the components that I was looking to replace is a MSMQ Message Processing application. Basically it is a custom written MSMQ Trigger service. Well.. here goes.

WCF includes a binding for interconnecting with non-WCF MSMQ implementations. I've created the final prototype from the basic service sample, and created a ServiceContract interface and implementation class

public interface IMessageProcessor
   [OperationContract(IsOneWay = true)]
   void ProcessMessage(MsmqMessage<Stream> msg);

public class MessageProcessor : IMessageProcessor
   public void ProcessMessage(MsmqMessage<Stream> msg)
      using (StreamReader sr = new StreamReader(msg.Body))
         MessageBox.Show("Hello: " + sr.ReadToEnd());

Then added created a main form, and added start/stop events
internal static ServiceHost myServiceHost = null;
internal static void StartService()
   // Instantiate new ServiceHost
   myServiceHost = new ServiceHost(typeof(MessageProcessor));
internal static void StopService()
   // Call StopService from your shutdown logic (i.e. dispose method)
   if (myServiceHost.State != CommunicationState.Closed)
private void MainForm_Load(object sender, EventArgs e)
private void MainForm_FormClosed(object sender, FormClosedEventArgs e)

The next step is to setup the app.config configuration file.

<?xml version="1.0" encoding="utf-8"?>
            <behavior name="Throttling">
               <serviceThrottling maxConcurrentCalls="2" />
         <binding name="NewBinding0" exactlyOnce="false" serializationFormat="Stream" />
         <service behaviorConfiguration="Throttling" name="WCFMQListener.MessageProcessor">
            <endpoint address="msmq.formatname:DIRECT=OS:.\private$\testqueue" binding="msmqIntegrationBinding" bindingConfiguration="NewBinding0" contract="WCFMQListener.IMessageProcessor" />

The most time I've spent was to figure out how to read the non-xml formatted message. The key is to declare the method as

void ProcessMessage(MsmqMessage<Stream> msg);

and to adjust binding in the configuration file


The message can be read just as easily as a binary array.


Wednesday, November 15, 2006

First experience in Office 2007 at work

I took a plunge, and installed Office 2007 RTM on my office PC. Here's the picture of my Outlook starting up

And that's about all it does... Since this is my only office PC, if I can not get this resolved today (And MS Premium Support is already involved) - its a clean rebuild!!!
Ohh well, its a good exercise..


Monday, November 06, 2006

Because of a nail...

Yesterday, I heard a great Japanese saying

"Because of a nail, a horseshoe was lost Because of a horseshoe, a horse was lost Because of a horse, a message was not delivered Because a message was not delivered, a war was lost"

Its a great way to reiterate the importance of the weakest link. It is something to apply in development, architecture, work in general and pretty life as a whole.

Directory of Computers/Tech Blogs