Search code examples
c#wcfinheritancenugetunity-container

Unity.Wcf / does not implement inherited abstract member AND no suitable method found to override


This class was generated by NUGET after installing Unity.Wcf

public class WcfServiceFactory : UnityServiceHostFactory
    {
        protected override void ConfigureContainer(IUnityContainer container)
        {
            // register all your components with the container here
            // container
            //    .RegisterType<IService1, Service1>()
            //    .RegisterType<DataContext>(new HierarchicalLifetimeManager());
        }
    } 

This is the class that is being inherited:

 public abstract class UnityServiceHostFactory : ServiceHostFactory
    {
        protected UnityServiceHostFactory();

        protected abstract void ConfigureContainer(IUnityContainer container);
        protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses);
    }

Somehow I keep getting these 2 errors:

'ServiceImplementation2.WcfServiceFactory' does not implement inherited abstract member 'Unity.Wcf.UnityServiceHostFactory.ConfigureContainer(Microsoft.Practices.Unity.IUnityContainer)'

and

'ServiceImplementation2.WcfServiceFactory.ConfigureContainer(Microsoft.Practices.Unity.IUnityContainer)': no suitable method found to override

There are no differences in the parameters.

Even autogenerating the method gets me errors.

I am using VisualStudio2013.


Solution

  • I had the same issue when working with Unity 4.0.1, but then the issue was disappeared after downgrade to Unity 3.5.1404. Looks to me like Unity.Wcf doesn't work well with 4.0.1.

    To install unity version 3.5

    Install-Package Unity -Version 3.5.1404

    Hope this help.