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…


Want a treat? Get others to send you an invite :P

Here’s an example of my “idle mind at work”… writing code just for the heck of it… SendKeys.SendWait(“^({ESC})”); Thread.Sleep(500); SendKeys.SendWait(“run”); Thread.Sleep(1000); SendKeys.SendWait(“{ENTER}”); Thread.Sleep(500);   String currentRecepients = “<your To List>”;//Enter all emails separated by semi colons   SendKeys.SendWait(“mailto:” + currentRecepients + “;”;//+ WindowsIdentity.GetCurrent().Name.Split(‘\\’)[1]); Thread.Sleep(500); SendKeys.SendWait(“{ENTER}”); Thread.Sleep(500); SendKeys.SendWait(“treat from me at barista… today 4:30pm”); SendKeys.SendWait(“{TAB}”); SendKeys.SendWait(“no…


Once I was a College Student

<re-published from my old blog> So there I was, sitting at my desk staring at the computer screen working on VS 2010 and exploring a bit of F#. I just sat back and started reflecting on my college days and the interviewing season in the 7th semester. All of us, revising all our technical knowledge,…


Creating your own Visual Studio code snippets

<re-published from my old blog>  Some time back I got thinking… everytime I start reading mails in the C# discussion alias at my company or Eric Lippert’s explanations of why the supposedly peculiar behaviour is in fact logical… the first thing I do is open up my very extensively used “ExperimentalConsoleApplication” solution in Visual Studio, comment…