WCF service hosted in IIS – "This collection already contains an address with scheme http" – Why does this happen?

I came across this error when I tried hosting a WCF endpoint from a website in IIS. This can be resolved by adding the following section in the web.config file     <serviceHostingEnvironment aspNetCompatibilityEnabled=”true”>       <baseAddressPrefixFilters>         <add prefix=http://www.myhost.com/ />       </baseAddressPrefixFilters>     </serviceHostingEnvironment>   Why does this happen? When you host a website using a…


Unhandled Error in Silverlight Application Code: 2103 Category: InitializeError Message: Invalid or malformed application: Check manifest

This is one weird error I encountered while creating a simple Silverlight application.  Scenario: Tested my application and post that I decided (for some reasons not relevant here) to change the namespace of the classes in my silverlight project. As part of this, I changed the namespace of the App class in the App.xaml.cs file….


Pef for fun – an interesting tool to promote TDD

Hi Folks, the PEX team has released on online version of their unit testing tool at http://www.pexforfun.com/ I found this to be a real fun way to explore and understand how Test Driven Development is all about. having said that, i’d like to add that PEX is much more than the above site. for more…


What happens when a constuctor is called

Consider the following class public class MyClass{    public int myField = 4;     public MyClass()    {        this.myField = 5;    }}  when we compile this class, we get an assembly with IL in it. The parameterless constructor gets converted into a method with the name .ctor Now, if we see the IL that gets generated for this .ctor method, we might expect it to have IL opcodes to assign the value…


what using the ‘using’ block in c# does to your code

Let us take a simple console application which has the below code written in it     class Program     {         static void Main(string[] args)         {             using (SqlConnection connection = new SqlConnection())             {                 connection.Open();                 connection.Close();             }         }     } the IL that gets generated for the above program…


How To: Enable multiple netTcp port sharing for WCF end-points

Getting straight to the point, the checklist for this can be found here. 3 basic tasks need to be done: – 1.       Enable port sharing by either adding an attribute in your code like below   NetTcpBinding binding = new NetTcpBinding(“netTcpBinding”); binding.PortSharingEnabled = true; serviceHost = new ServiceHost(typeof(MsiFacade35Service)); serviceHost.AddServiceEndpoint(typeof(IMsiFacade35Service), binding, “net.tcp://MyServer/MyServiceEndpoint”);   Or by setting…


Nice to have C# 5.0 LinQ feature

currently LinQ only supports projections, instead if we could perform an action for each row inside the linq query itself it would be great.  I had in mind something like the below query in mind. Hopefully C# team would consider this 🙂 Collection<DataEndpoint> myObjects = new Collection<DataEndpoint>(); var dataExtensions = from c in dataContext.ETDataExtensions                      join…