I suspected the host service was not an instance of the service class, and Carlos Figueira confirmed that in his answer to [Do I need Dispose () when using the custom ServiceHostFactory?] .
CreateServiceHost() in the factory was called several times for my application, throwing an ArgumentException the second time it was initialized, with the message:
The value could not be added to the collection, as the collection already contains an item of the same type: ....
WCF sometimes reuses a service host. I worked on the problem by checking if any of my configured actions were already on the list of servicehost Description.Endpoints.Behaviors , so I did not initialize my service host a second time. In practice, my case was simpler because I installed the ServiceAuthorizationManager ; if I find that it is already installed, I no longer avoided initializing anything.
source share