Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ServiceHostFactory missing in .NET 4.0?

Tags:

This is driving me nuts, maybe I'm missing something but I'm trying to upgrade a .NET 3.5 application to .NET 4.0 and the only problem I'm running into is this class:

3.5 Code:

   public class ServiceHostFactory : System.ServiceModel.Activation.ServiceHostFactory     {         protected override System.ServiceModel.ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses) {             return new ServiceHost(serviceType, baseAddresses);         }     } 

When I upgrade to 4.0, it appears that "ServiceHostFactory" doesn't exist (it is red). Going into Object Browser, under System.ServiceModel.Activation, it indeed shows no ServiceHostFactory.

According to this:

http://msdn.microsoft.com/en-us/library/system.servicemodel.activation.servicehostfactory.aspx

It should be supported in 4.0. What am I missing here?

like image 713
chum of chance Avatar asked Aug 31 '10 14:08

chum of chance


1 Answers

The System.ServiceModel.dll has some items in the System.ServiceModel.Activation namespace.

However, ServiceHostFactory is in the System.ServiceModel.Activation.dll itself. So you need to add a reference to that assembly. Keep in mind that by default, VS2010 appears to want to use the .NET 4 Client Profile, so you'll need to change that to the regular .NET 4 profile before you can add the reference to System.ServiceModel.Activation.

like image 87
Brad Nabholz Avatar answered Oct 14 '22 08:10

Brad Nabholz