Galin Iliev's blog

Software Architecture & Development

Hosting WCF service over net.tcp protocol in IIS7 (WAS)

There are several articles showing how to host non-http protocols on IIS7. Some steps are like black box while others could easily be misconfigured. 

The tasks is complicated additionally by obscured error messages returned in the browser :)

So let’s started (the example below is in Windows Server 2008. In Vista/Windows7 is similar but not exactly same):

Phase 1: Prepare server (prerequisites)

1. Add Web Server Role

  • Select following features as a minimum:
  • Common HTTP Features - all
  • Application Development
  • .NET Extensibility
  • ISAPI extensions
  • ISAPI Filters
  • Security – all

2. Add Application Role

Add Application Server role and select all features (confirm all dependencies):


With this Phase 1 is complete. We should be able to navigate to Internet Information Services (IIS) Manage console in Administrative tools.

Phase 2: Deploying WCF application

1. Build WCF application with netTcpBinding :) (kindda obvious). For service endpoints leave address relative or empty.

   1: <services>
   2:   <service name="Microsoft.Test.Service" behaviorConfiguration="Service.ServiceBehavior">
   3:     <!-- Service Endpoints -->
   4:     <endpoint name="netTcp" address="" binding="netTcpBinding" bindingConfiguration="bigMessages" contract="Microsoft.Test.IService" />
   5:     <endpoint name="mexNetTcp" address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
   6:   </service>
   7: </services>

2. Create website that will host it in IIS

Since it is not a challenge to create it via IIS Manager here is how it can be achieved via script (JS). This can be used as custom action in WiX/MSI as well

   1: var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
   2: adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
   4: var sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST");
   6: var sitesCollection = sitesSection.Collection;
   8: var siteElement = sitesCollection.CreateNewElement("site");
   9: siteElement.Properties.Item("name").Value = "WcfNetTcp";
  10: siteElement.Properties.Item("id").Value = 7;
  12: var bindingsCollection = siteElement.ChildElements.Item("bindings").Collection;
  14: var bindingElement = bindingsCollection.CreateNewElement("binding");
  15: bindingElement.Properties.Item("protocol").Value = "http";
  16: bindingElement.Properties.Item("bindingInformation").Value = "*:80:";
  17: bindingsCollection.AddElement(bindingElement);
  19: var siteCollection = siteElement.Collection;
  21: var applicationElement = siteCollection.CreateNewElement("application");
  22: applicationElement.Properties.Item("path").Value = "D:\\Hosting\\WcfApp";
  23: applicationElement.Properties.Item("applicationPool").Value = "DefaultAppPool";
  24: siteCollection.AddElement(applicationElement);
  26: sitesCollection.AddElement(siteElement);
  28: adminManager.CommitChanges();

3. Add net.tcp protocol:

Here is how it should look from GUI:


And the script for it

   1: var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
   2: adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
   4: var sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST");
   6: var sitesCollection = sitesSection.Collection;
   8: var siteElementPos = FindElement(sitesCollection, "site", ["name", "WcfNetTcp"]);
   9: if (siteElementPos == -1) throw "Element not found!";
  10: var siteElement = sitesCollection.Item(siteElementPos);
  13: var bindingsCollection = siteElement.ChildElements.Item("bindings").Collection;
  15: var bindingElement = bindingsCollection.CreateNewElement("binding");
  16: bindingElement.Properties.Item("protocol").Value = "net.tcp";
  17: bindingElement.Properties.Item("bindingInformation").Value = "809:*";
  18: bindingsCollection.AddElement(bindingElement);
  20: adminManager.CommitChanges();

4. Enable net.tcp for website (Virtual Application) that hosts Wcf Service – in this example we’re hosting in the root of website


And of course the script:

   1: var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
   2: adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
   4: var sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST");
   6: var sitesCollection = sitesSection.Collection;
   8: var siteElementPos = FindElement(sitesCollection, "site", ["name", "WcfNetTcp"]);
   9: if (siteElementPos == -1) throw "Element not found!";
  10: var siteElement = sitesCollection.Item(siteElementPos);
  12: var siteCollection = siteElement.Collection;
  14: var applicationElementPos = FindElement(siteCollection, "application", ["path", "/"]);
  15: if (applicationElementPos == -1) throw "Element not found!";
  16: var applicationElement = siteCollection.Item(applicationElementPos);
  18: applicationElement.Properties.Item("enabledProtocols").Value = "http,net.tcp";
  20: adminManager.CommitChanges();

Warning: Do not put any spaces in “Enabled Protocols” field. Although it might works for HTTP it doesn’t for net.tcp.

5. (Optional) Run in elevated mode (As Administrator):

   1: “%WINDIR%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" –i

I will cover why it is optional in next posts.

Note: Scripts are generated using IIS 7.5 IIS Management console and Windows 7

Hope that helps.

P.S. Here is the helper js function FindElement(). It is slightly modified from original generated by IIS Manager so it will compare values in case insensitive way.

Getting started with Silverlight

Tim Heuer posted a great series of articles targeted a new Silverlight developers. These can be used to ramp up with new things in v3 as well as Silverlight concepts.

Original post here.

SQL on Saturday

I am attending a very interesting even called SQLSaturday at the newest MS building complex The Commons. This is a three track event about SQL server and has very interesting topics. Speakers are MVPs form northwest and MSFTs.

This event is held in different locations in USA. It is highly recommended for DB devs and admins who want to learn some tips, trick and get some advises learned hard way.

Silverlight Firestarter in Redmond

Recently there was a Silverlight Firestarter event in Redmond:

When you wake on Sept. 17th the year of 2009 you have a smile on your face. Not only did you get the day of for “training”, but the “training” is actually something you’re very interested in.  Maybe you haven’t had the chance yet, or you’re looking for additional guidance; but today you’re going on a tour of Silverlight 3, Expression Blend, SketchFlow, the Silverlight Toolkit, RIA Services and XAML Power toys.

Since this event is in the past there is still a way to catch up: Tim Heuer and Mithun posted videos from the event and I highly encourage all interested in Silverlight 3 to look at them.


Started silverlighting…

I haven’t blogged for a while since I have been enjoying non-typical sunny and hot summer here at Washington.

Now the summer is over and it is time to go back into tech area. Since you’ve noticed there are no WPF/Silverlight posts on my blog and this is about to change :)

I got new laptop and after installing recently released RTM of Windows Server 2008 R2 RTM and converted to workstation. For more details you can see previous posts. And of course it contains booting from VHD… multiple VHDs. I think this is great new feature that speeds up testing and playing with different technologies a lot…

AdCenter team is hiring

AdCenter test team is expanding and there are open positions at different levels. If you want to be part of long discussed Microsoft-Yahoo deal, to take part of ensuring top quality of our products and services and working in the biggest software company and yet in a new field for it drop me your resume at the email on contact page.

Here are some job descriptions:

Senior Software Development Engineer in Test

We are looking for a Senior SDET for the Search Advertising area within RnR, who is excited to take on these challenges. You will drive innovations in test by building quality test tools, test automation and breakthrough test technologies. You will help structure our algorithm experiments in an adaptive trials framework. You should be comfortable with sampling methods and be able to dive in and diagnose inconsistencies with our current sampling strategies and design meaningful experiments while improving the experimentation systems.
A successful candidate will have 7+ years of strong technical experience; 7+ years of broad testing experience; 5+ years of strong hands on product development or test development work, effective written and oral communication skills; engineering experience acquired from shipping multiple large commercial software products or online services; ability to influence all disciplines on quality and product strategy decisions; and ability to experiment sophisticated algorithms and statistical models highly desirable. Degree in Computer Science or equivalent experience required.


Software Development Engineer in Test

We are looking for talented, innovative and highly motivated SDETs with strong technical and design skills to help us assure that the web components of AdCenter, as part of our highly scalable multi-tiered advertiser management system, meets the highest quality standard. You will have the opportunity to impact the architecture of these core platform services, and at the same time be challenged with building world class test automation and tools. As an SDET, your primary responsibilities include test plan and test case preparation to ensure test coverage and test methods are appropriate. You will also participate in critiquing functional and technical specification reviews, establishing test infrastructure, rapid automated testing of features, adapting to changing requirements/processes, enforcing Engineering Excellence practices, and driving quality upstream in all phases of development. You are encouraged to adopt more creative test methods to meet the needs of agile development process so as to keep the testing with right coverage on schedule.
You possess the following skills:

  • Understand software testing methodology and experience in test automation tool development.
  • Strong analytical and problem-solving abilities.
  • Passion for product quality and solving complex automation problems.
  • Knowledge of Internet based services, Web technologies.
  • Familiarity with IIS/XML Web Services.
  • 3+ years of software development and/or test experience with fluency in C# and ASP.NET.
  • BA or BS in Computer Science or related discipline.
  • Familiarity with SQL Server, web services and multi-tiered client and server distributed applications is preferred.
  • Experience with the following technologies is a plus:
    o VS Team Edition for Testers
    o TFS
    o KAF
    o Selenium

Systems Engineer

Key Responsibilities:
Automate - Develop production quality solutions to reduce risks in manual task and drive efficiency.
Optimize and innovate - Tuning and optimization tactics and build systems management automation and tooling capabilities.
Analyze trends- Provide systems statistical trending and analysis, server capacity and threshold testing.
Evaluate systems and technology - Assess new systems designs and technical strategies.
Evangelize - Represent operations team on technical, product direction and service quality.
Deliver - Deploy and Operate large scale systems.
Maintain - Maintain and manage Enterprise san and servers.

Strong knowledge in Windows OS (Windows 2003 and Windows 2008) is must.
Strong knowledge in TCP/IP and networking is a must.
Scripting in VB, Powershell, Perl, and Telnet is must.
IIS and SQL knowledge is desired.
Virtulization knowledge is desired.
A minimum of 5 years of demonstrated work experience in IT.
Minimum of 5 years in SAN. Experience in EMC SAN (DMX and Clariion) and Brocade SAN switch is preferred.
Strong knowledge in storage and raid.
Strong knowledge in Servers (Processor, Bus, and Memory). Experience in HP servers is preferred.

Windows 7 RTM – code fully cooked

Today Microsoft announced that Windows 7 and Windows Server 2008 R2 code is signed off and is ready to go to manufacture – so this will be the code that end user will use.

Even more - partners and business customers can get their hands on Windows 7 RTM code starting next month.

I have been using Windows 7 and Windows Server 2008 R2 since their Beta and I dare to say that this is the fastest OS, I’ve ever worked with. You will like it for sure.

Both client (Windows 7) and server (Windows Server 2008 R2) are full with improvements and for sure these increase both the pleasure and the productivity.

How to turn Windows Server 2008 R2 into workstation with Aero

After I was using Windows Server 2008 as a workstation for a while I decided to move to R2.

Having the option to boot form VHD it was a nice idea- I could have as many OS-es as I want and they fully utilize the hardware. But one question remained: How I can turn Windows Server 2008 R2 into workstation and having all goodies of workstation including Aero interface.

The default installation seems to have following notable features:

  • Only x64 editions
  • Less driver support than Windows 7
  • No audio
  • Wireless disabled by default (after installing the driver)
  • Cannot select Windows 7 theme even after video driver selection.

So let’s nail those one by one:

Only x64 editions

Well… nothing can be done here. Time to move to x64 bit platform. Fortunately my laptop’s CPU was Intel Core2 Duo and can do it.

Less driver support than Windows 7

Luckily Windows 7 drivers work – as long as they support x64 bit. I had a hard time to find some for my Dell machine though… Note: Windows Vista x64 drivers worked for me as well…

No Audio

This was easy. The drivers were in place (with installation) and only had to play with some services:

  • Windows Audio
  • Windows Audio Endpoint Builder


I just started the first one and there was sound J

Wireless disabled by default

This was tough one (for me). I installed correct drivers. Everything seemed normal except I couldn’t enable the adapter. It was constantly disabled.


After every attempt to enable it remained disabled. In Event viewer I saw the following message:

Application popup: BCMWLTRY.EXE - System Error : The program can't start because Wlanapi.dll is missing from your computer. Try reinstalling the program to fix this problem.

The solution was to add the feature “Wireless LAN Service”


Just go to “Server Manager”, select Features from the tree on the left and select “Add Features”


Enable Aero theme.

This one was tough as well… I had to do several steps:

  1. Install video driver
  2. Add “Desktop experience” feature (together with .NET Framework 3.5.1)
  3. Start “Theme” Windows service.

4. Select performance options from System applet in Control Panel

5. Select theme from “Personalization” window


Happy binging! :)

Remote Desktops MMC for Windows 7

A while ago I blogged how to re-enable remote desktops MMC for Windows Vista. This feature has different names and it was hard to find initially :) In a comment one reader posted a way to enable it via “Programs and Features” – > “Turn Windows features On and Off” as suggested to search for “Remote Server Administration Tools"\"Role Administration Tools".

With Windows 7 it is different.. again. But this time no file copy and DLL register. First you need to download and install Remote Server Administration Tools for Windows 7.

And then navigate to “Programs and Features” –> “Turn Windows features on and off”:


Hope this helps