Suppose an enterprise has a set of services that it feels can be exposed to the internet for business or for its own usage, there are two ways to address it.
1) Setup the services on a DMZ thereby exposing the services in a secure manner to the internet.
2) Open up ports on the enterprise firewall to allow inbound access from outside machines to the services running. [This is not allowed as it has the potential to allow users to exploit the enterprise network]
The first mode of setting up a DMZ is the preferred way, but its limitation would be allowing access of DMZ machines onto the enterprise network. If the DMZ needs to access internal systems like a Mainframe, then there could be deployment and security issues.
The Microsoft .NET services (or the BizTalk Services as it was previously called) allows enterprises to expose their services to the internet from within a firewall without having to setup a DMZ or allow explicit inbound access to the machines. It used the concept of Relay Binding (extension over the existing WCF) to allow access to the services. Allowing disparate systems to be interconnected through the internet, the .NET services sets up an internet service bus in the Microsoft cloud.
Some of the offerings of .NET Services are:
1) Access Control Services or Identity Services: it is a hosted service that enables enterprises easily manage its users supporting user identities from various organizations
2) Connectivity Services: These services make connectivity between services in different enterprises feasible. We could host a service from within Infosys Firewall and it could be consumed by a customer in another enterprise or on the internet. It allows enterprises to expose services through the .net services as a URI which is accessible over the internet. In practice, the actual URL and Machine of the service is hidden from the client applications.
3) Workflow Services: A new addition to the .NET services, it allows execution of Windows Workflow Services that orchestrate the interactions between other services hosted via the ISB.
4) .NET framework extensions that allow connecting to the ISB through applications
The Connectivity Services relies on using RelayBinding
Applications that need to use connectivity services establish outbound connections (allowed by enterprises) to the service bus. This would be done by both the sending as well as receiving applications.
When an application listens on an endpoint, it automatically polls the Connectivity Service to retrieve incoming messages. In a simple example, suppose applications in two distinct enterprises send and receive messages through the WCF framework and APIs. Enterprise A establishes an outbound connection to the Connectivity Service, and begins listening on an endpoint, defined by the URI labs.biztalk.net/enterpriseA/someapp. Enterprise B also establishes an outbound connection to the Connectivity Service, and sends a message to the same URI. The Connectivity Service receives the message, and relays it to the application in enterprise A, via its already open connection. The SDK simplifies developing applications that use the .net services, and enables existing applications to use the service bus without modifications.
In cases where Direct connection is possible, the service bus would first establish a relay connection and then make a direct connection between the applications. The connectivity service internally calls the identity services to authenticate the users. The steps to start working on service bus are.
1) Create an account on the http://labs.biztalk.net site.
2) Download the .net services SDK and install it on the machine.
3) If the machine is within a firewall then open outbound connections to 65.55.22.* and 65.22.20.* IP range over the following ports 808, 809, 818 and 819. Install the Winsock client so that access to the BizTalk service machines is available. [This is required because the relay mechanism internally uses TCP connections to ensure connectivity with the Service bus]. Now we are set to start using the sample applications.
There are many sample applications available in the SDK that showcase the various abilities of the Service bus like Relay connection, multicast, Direct connection, Http based file sharing and Workflow. The .NET services offer a simple way for enterprises to share their services across the internet without having to put them on a DMZ or another hosting service. This blog from Clemens Vasters has a good amount of information about .NET services.
1. Better support for side by side, where in you can have CLR 2.0 and 4.0 in the same host process. This will be specifically useful for addins.
2. No more PIA (primary interop assemblies) to worry about.
3. New signature generation tool that can look up windows.h to generate p/invoke signatures. The tool will be on code plex shortly.
4. .NET supported 16 languages, but no support for dynamic languages and functional language. Iron Python, Iron Ruby and F# will now be supported.
5. Big integers support added in BCL (base class library) so any language on top can leverage it. For more details on BCL changes check here.
6. Tuples supported in F# and Iron Python. It is more used for making new classes or allows functions to return multiple values. This is now added to BCL so langauge interop becomes easy.
7. Tail recursion optimizations done in F#. C# compiler still doesn't support this.
8. .NET Framework now installs faster and applications can startup faster. Installation and NGEN is done in parallel. Startup times improvements due to layout optimizations and can result in upto 40% improvements in some applications.
9. .NET applications can now run from network share with full trust, so it is easy to deploy applications. This feature has been added in .NET 3.5 SP1 itself.
10. Improvements in threading to take advantage of multi-core machines. Thread pool code improved in conjunction with task parallel library implementation.
11. Support for background GC.
12. Better profiling support with ability to attach/detach performance and memory profilers to production servers without having to install
13. Using catch(Exception e) is bad since it will catch all exceptions include access violation, illegal instruction (exceptions that corrupt the state) etc. Going foward to handle this, you will have to use the [HandleProcessCorruptedStateExceptions] attribute at the function level.
14. Dump debugging simplified by supporting ICorDebug to debug dumps right from Visual Studio. Also new lock APIs are available to help find more details about locaked objects.
15. Code contracts are powerful new constructs that can help write assert and post condition type statements, but in a more powerful manner. Static analysis tools can understand these and identify violations without you even running the code. To know more about code contracts and how they work well with unit testing to help improve the code quality, check this pdc session.
However when we configured the specific applications on IIS, and tried to browse to the WCF's SVC file, we got a 404.3 as seen in the figure below.
Essentially what this shows is that IIS isn't configured correctly and when you try to access the service details by accessing the SVC file, IIS is unaware on how to handle this request. The resolution shown here can be a bit misleading. The mime map option isn't right since what we want is to be able to execute the SVC file on server and not really return it as some kind of stream from IIS. For execution, appropriate http module and handlers need to be registered with IIS. This can be done via the IIS Admin console or directly editing the applicationHost.config file (filepath - C:\Windows\System32\inetsrv\config). The following changes are required.
Add the following handlers to the file inside of section "<location path="" overrideMode="Allow">"
<add name="svc-ISAPI-2.0" path="*.svc" verb="*" modules="IsapiModule" scriptProcessor="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv2.0,bitness32" />
<add name="svc-Integrated" path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=22.214.171.124, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="integratedMode" />
and also in the same section add the following module
<add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel, Version=126.96.36.199, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" />
While you can manually change the file to do this, it is much easier to do this via the "Turn Windows features on or off" (via Control panel). Apart from the config file changes, there could be other configurations related to specific security settings etc (I haven't tried to find out as yet) could be required that will be taken care via this setup.
The "Windows Communication Foundation HTTP Activation" is not enabled by default. You can check that and click OK and this will do the necessary configurations along with making the changes to the applicationHost.config file as I mentioned above.
With these done, when I browsed my service's SVC file again. I got the familiar screen as seen below and got the service working fine.
If you have been following updates on Silverlight (SL) 2, you would already be aware of SL 2 Toolkit on codeplex. Scott in his blog has shared some amazing numbers on usage of SL and also given some indicators to where SL is headed in its next version.
I had been away from SL for some time due to other focus areas. However I decided to try my hands on the support for themes, a feature added with SL Toolkit.
This intro by Jesse Liberty amazed me. The theme seemed so trivial to use. The basic idea on these being available as controls that I could drop on my form and embed other controls inside of it was amazing. I decided to give this a try and started with my sample application. While building this, I observed a few things, which I wanted to capture and share
I am surprised why debug execution gives an error while run doesn't (point 5). If anyone has found out a reason, please share.
You can handle the AppDomain.UnhandledException event to attempt to save some state/information as may be required and possible, but you can't stop the application from terminating. Note however that if a similar unhandled exception is raised from the main thread (of a winform application), the application may not terminate.
MSDN excerpt - "In applications that use Windows Forms, unhandled exceptions in the main application thread cause the Application..::.ThreadException event to be raised. If this event is handled, the default behavior is that the unhandled exception does not terminate the application, although the application is left in an unknown state."
To see this behavior, check the following code. In the Form1, I have added 2 buttons (button1 and button2). In the button1 code, I raise an exception, so this acts as an exception on the main thread itself. In button1 code, I start a new thread and then raise an exception in the thread function.
private void button1_Click(object sender, EventArgs e)
throw new NotImplementedException();
private void button2_Click(object sender, EventArgs e)
Thread th = new Thread(new ThreadStart(func));
throw new NotImplementedException();
Finally, in the program.cs, I have added an event handler to handle the thread exception.
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
To see the actual behavior, you should run the application and not debug it. In case of the button1 exception, you get a framework provided message box that allows you to handle the exception and continue executing the application. In case of the button1 exception, you will see the message box as per the code in the event handler that I have written in program.cs (as shown above), and after you click OK on the message box, the application terminates.
So back to the question we started with. Essentially the solution lies in not throwing the exception from the thread, but handling it in the thread method itself and instead firing an event that the main thread can handle and get details on the exception. The good news is that this behavior has already been provided in BackgroundWorker class. See the modified logic for button2 code to show how this works.
private void button2_Click(object sender, EventArgs e)
BackgroundWorker worker = new BackgroundWorker();
worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
void worker_DoWork(object sender, DoWorkEventArgs e)
throw new NotImplementedException();
void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
if (e.Error != null)
In case of exception the RunWorkerCompletedEventArgs.Error property is set and the details on the same can be obtained in the RunWorkerCompleted event handler. If you are interested, you can always debug into the framework code to see the details. The following code snippet shows how this is implemented in the BackgroundWorker.cs class
private void WorkerThreadStart(object argument)
object workerResult = null;
Exception error = null;
bool cancelled = false;
DoWorkEventArgs doWorkArgs = new DoWorkEventArgs(argument);
cancelled = true;
workerResult = doWorkArgs.Result;
catch (Exception exception)
error = exception;
RunWorkerCompletedEventArgs e =
new RunWorkerCompletedEventArgs(workerResult, error, cancelled);
You can see the main execution logic on the BackgroundWorker is inside of a try catch block and the exception obtained is set to the Error property of the RunWorkerCompletedEventArgs class.
Hope this helps.
One of my colleague, Archana Sachin Ghag who is a key member of our software factory team has just finished writing a Blueprints Walkthrough. I am sharing this walkthrough with rest of the development community hoping it may act as a jumpstart for your Blueprints adoption.
Before you start creating your own Blueprint using Microsoft’s Blueprint Manger go through this article which introduces Blueprint Concept and Blueprint Manager. To start building your own Blueprint, Blueprint Manager comes with “Microsoft Blueprint Factory” which is nothing but a Blueprint itself.
When you select “Microsoft Blueprint Factory” from Blueprint Manager and click “Unfold”, it prompts for project you want to unfold this Blueprint Factory. I usually prefer Blank Solution to unfold Blueprint Factory.
Before unfolding starts, user will be prompted for the project name.
By default, the name is shown as BlueprintFactory. You can change the name according to your requirements. I will say it as MyFirstBlueprint.
Unfolded project in blank solution will look like this.
When you right click MyFirstBlueprint project you get a context menu with caption “Blueprints” containing different options to configure various aspects of the blueprint.
Note: Menu item Blueprints is the key for Blueprint development. All guidance is provided through this menu. Whenever a blueprint is unfolded on a machine, it adds a blueprint context menu item specific to this unfolded blueprint which provides guidance to the developer.
Next step is to configure my Blueprint. Click Blueprints -> Edit Configuration. Blueprint will display Blueprint Editor which allows user to configure all possible options available with blueprint viz.
1. General Configuration
5. Related Blueprints
6. Installation Actions.
In this article we will see some of the general configuration settings and further discuss how to implement commands and menus in our custom blueprints.
Edit Configuration will show the following dialogue box.
On Configuration Tab you can configure
1. Project Name- This name will be used during unfolding of projects and it is also important as far as build artifacts of blueprint is concerned. When we build Blueprint project it creates a zip file containing all information for RSS. The name of this file will be <ProjectName>-RSS.zip. Build will also generate folder named ‘ProjectName_Pacakge’. This contains all files needed to run blueprint. To see all this information you have to open Windows Explorer after build and see your blueprint directory. You cannot see this information in Visual Studio itself.
2. Type of Blueprint can be Microsoft or Third Party or hidden.
3. Publisher will be your company name.
4. You can also give RSS feed link here. This is very important from a delivery and deployment perspective as Blueprints Manager can update existing blueprints through this RSS Feed whenever a new version is available from within Visual Studio IDE itself.
We will now see how to use Commands and Menus Tabs to create our own Menu option for “Blueprints”.Each menu item has command associated with it. On click of this menu item, command associated with it gets executed.
Blueprint shows/executes its commands or menus from .Net library called Blueprint Extension Library. This library has to follow some standard so that blueprint understands it properly.
1. Assembly name for extension library should start with Blueprint’s project name.
2. Class which handles commands must derive from ‘BPMExtensionBase’ from ‘Microsoft.SoftwareFactories.Blueprints’
3. You must copy the extension library to “extensions” folder inside “MyFirstBlueprint” project folder.
Click Blueprints -> Add Extensions to create a new extension.
It will add extension library project to the solution and set Assembly Name as required by the blueprint. Specify project name for extension using the following dialog box.
Now solution will look like this
MyExtensions project contains class “ExtensionClass” with a sample command implemented that will help you to implement your own commands. You get Menu “Blueprints” even on MyExtensions project which will give option to see workflow which will give step by step guidance on how to use this project for your blueprint. Modify class ExtensionClass to implement your own commands. Build MyExtensions project using Visual Studio.
Now the next step is to specify commands from MyExtension which will be used by “MyFirstBlueprint”. For this we will again click on Blueprints -> Edit Configuration menu to get Blueprint Editor. Open Commands Tab.
Add new command and fill the details as follows
Once command is added, the only step remains is to associate this command with a Menu Item. Create new Menu Item using Blueprint Editor’s Menus Tab.
Visibility has many options supported as Filters. You can see all available Filters from Blueprints -> Workflow menu item. These filters decide for which project or project item you want to show this context menu item.
Save both projects and build them. Once built and auto install is successful, you can see your blueprint entry in Blueprint manager. Unfold it and see whether you get custom menu created by you.
NOTE. Remember you have checkbox “Custom Menu Filters” checked on Blueprint Manager to see your own menus.
Hope this helps to quick start Blueprint development. Once Menus are appearing you can write whole lot of customized stuff in your commands to auto generate repetitive code or provide any kind of guidance needed.
In the recently held PDC 2008, Microsoft announced Azure, a cloud platform from Microsoft which comprise of the following technologies:
We are working closely with Microsoft on these set of technologies to understand and in turn realize the learning’s into real life solutions that will benefit our customers in their businesses. Through these blogs we shall attempt to share learning’s and developments happening on the Microsoft cloud platform aka Azure.
Here's something that I accidently noticed today. Inside of a command prompt, of you type "cmd" (to launch a commonad prompt), it treats this as a new instance, though no new windows is opened. Now if you type "exit", the command window still stays since there were effectively two instances. Only when you type "exit" the second time, will the command window close.
This can go on at any level (I didn't really try too many levels). You can also easily make out the # instances by looking at the title bar. Every time you type "cmd" at a command prompt, you will see "- cmd" get added to the title. With every "exit" one of these goes away till you are back to the default title you had started up with and another "exit" will close the window.
I am simplifying the logic we have in our application to showcase here and it is pretty much same as what Avi has shown.
public static string commandArgs = string.Empty;
protected override void OnStartup(StartupEventArgs e)
if (e.Args!= null && e.Args.Length > 0)
commandArgs = e.Args;
We have some custom file extension that we have associated with our application. And on double clicking such a file, our application launches and we still very much get the file name as part of command line arguments, without having to worry about accesssing it from AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData.
And we have been working with .net 3.5 and our code works both without SP1 and with SP1