none
Getting error while accessing vs 2012 WCF service created using Castle Windsor in IIS 7. RRS feed

  • Question

  • Hello,

    I am getting the below error while accessing the VS 2012 WCF service using Castle Windsor in IIS7, the same service works in IIS6.

    Please let me know in case WCF service details is required.

    Error Description:


    An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
    System.InvalidOperationException: This value cannot be changed after the ServiceHost has opened.
       at System.ServiceModel.Dispatcher.SharedRuntimeState.ThrowIfImmutable()
       at System.ServiceModel.Dispatcher.DispatchRuntime.InvalidateRuntime()
       at System.ServiceModel.Dispatcher.DispatchRuntime.set_InstanceProvider(IInstanceProvider value)
       at Absg.eCommerce.ContainerInstanceProviderBehaviorAttribute.AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection`1 endpoints, BindingParameterCollection bindingParameters)
       at System.ServiceModel.Description.DispatcherBuilder.GetBindingParameters(ServiceHostBase serviceHost, Collection`1 endpoints)
       at System.ServiceModel.Description.ServiceMetadataBehavior.MetadataExtensionInitializer.GenerateMetadata()
       at System.ServiceModel.Description.ServiceMetadataExtension.EnsureInitialized()
       at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.InitializationData.InitializeFrom(ServiceMetadataExtension extension)
       at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.GetInitData()
       at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.TryHandleDocumentationRequest(Message httpGetRequest, String[] queries, Message& replyMessage)
       at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.ProcessHttpRequest(Message httpGetRequest)
       at SyncInvokeGet(Object , Object[] , Object[] )
       at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
       at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
       at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)



    Saturday, September 28, 2013 6:05 AM

Answers

  • Hi,

    When the WCF service useCastle Windsor in IIS, if the binding used for the wcf service isn’t based on http then the Applicaton_Start method in global.asax.cs won’t be called before the service is invoked. This will cause a problem if our serivce has dependecies that need to be injected. To setup the container used to resolve dependencies we create a class in the App_Code folder under the website that has a method with the following signature: public static void AppInitialize() this method will be called before our service is invoked the first time so it is a perfect place to setup our IoC container.

    A simple registration would look like this:

    public class AppInit
    
    {
    
      private static IWindsorContainer _container;
    
      public static void AppInitialize()
    
      {
    
        _container = new WindsorContainer();
    
        _container.AddFacility<wcffacility>();
    
        _container.Register(Component.For<iservice>().ImplementedBy<service>());
    
      }
    
    }

    The last thing to do is in the Serivce.svc markup add the castle factory attribute: Factory=”Castle.Facilities.WcfIntegration.DefaultServiceHostFactory, Castle.Facilities.WcfIntegration”.

    For more information, please try to check:
    http://blog.tacticalnuclearstrike.com/2012/08/nonhttp-wcf-services-in-iis-and-castle-windsor/ .

    And it will be better if you can try to enable the WCF tracing to find the cause.

    #How to enable the WCF tracing:
    http://msdn.microsoft.com/en-us/library/ms733025.aspx .

    Best Regards,
    Amy Peng


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Monday, September 30, 2013 2:55 AM
    Moderator

All replies

  • Hi,

    When the WCF service useCastle Windsor in IIS, if the binding used for the wcf service isn’t based on http then the Applicaton_Start method in global.asax.cs won’t be called before the service is invoked. This will cause a problem if our serivce has dependecies that need to be injected. To setup the container used to resolve dependencies we create a class in the App_Code folder under the website that has a method with the following signature: public static void AppInitialize() this method will be called before our service is invoked the first time so it is a perfect place to setup our IoC container.

    A simple registration would look like this:

    public class AppInit
    
    {
    
      private static IWindsorContainer _container;
    
      public static void AppInitialize()
    
      {
    
        _container = new WindsorContainer();
    
        _container.AddFacility<wcffacility>();
    
        _container.Register(Component.For<iservice>().ImplementedBy<service>());
    
      }
    
    }

    The last thing to do is in the Serivce.svc markup add the castle factory attribute: Factory=”Castle.Facilities.WcfIntegration.DefaultServiceHostFactory, Castle.Facilities.WcfIntegration”.

    For more information, please try to check:
    http://blog.tacticalnuclearstrike.com/2012/08/nonhttp-wcf-services-in-iis-and-castle-windsor/ .

    And it will be better if you can try to enable the WCF tracing to find the cause.

    #How to enable the WCF tracing:
    http://msdn.microsoft.com/en-us/library/ms733025.aspx .

    Best Regards,
    Amy Peng


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Monday, September 30, 2013 2:55 AM
    Moderator
  • Thanks for the reply.

    I will try the different ways mentioned in the post...

    Monday, September 30, 2013 2:50 PM