You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Autofac WCF service doesn't initialize in Singleton mode if Autofac Interceptors are also configured.
Steps to Reproduce
Sample WCF service project is provided in below github repo. Just set the WCFService as startup project and Service1.svc as Start page and run, you will get the error as
Error is coming when we are configuring the service as SingleInstance and Enabling the Interceptors at the same time. If we remove anyone from these, then service works fine. i.e. If we remove the Interceptor OR we remove the SingleInstance (and remove InstanceContextMode from ServiceBehavior), then Service works fine
Service should run fine with both configurations i.e. Interceptors with SingleInstance service
Exception with Stack Trace
<TITLE>The service class of type Castle.Proxies.IService1Proxy both defines a ServiceContract and inherits a ServiceContract from type ClassLibrary1.IService1. Contract inheritance can only be used among interface types. ÿIf a class is marked with ServiceContractAttribute, it must be the only type in the hierarchy with ServiceContractAttribute. ÿConsider moving the ServiceContractAttribute on type ClassLibrary1.IService1 to a separate interface that type ClassLibrary1.IService1 implements.</TITLE>
Error: Cannot obtain Metadata from http://localhost:60837/Service1.svc If this
is a Windows (R) Communication Foundation service to which you have access,
please check that you have enabled metadata publishing at the specified address.
For help enabling metadata publishing, please refer to the MSDN documentation at
http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI:
http://localhost:60837/Service1.svc Metadata contains a reference that cannot be
resolved: 'http://localhost:60837/Service1.svc'. The requested service,
'http://localhost:60837/Service1.svc' could not be activated. See the server's
diagnostic trace logs for more information.HTTP GET Error URI:
http://localhost:60837/Service1.svc There was an error downloading
'http://localhost:60837/Service1.svc'. The request failed with the error
message:--
<STYLE> body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:pointer; } @media screen and (max-width: 639px) { pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; } } @media screen and (max-width: 479px) { pre { width: 280px; } } </STYLE>
Server Error in '/' Application.
The service class of type Castle.Proxies.IService1Proxy both defines a
ServiceContract and inherits a ServiceContract from type
ClassLibrary1.IService1. Contract inheritance can only be used among interface
types. ÿIf a class is marked with ServiceContractAttribute, it must be the only
type in the hierarchy with ServiceContractAttribute. ÿConsider moving the
ServiceContractAttribute on type ClassLibrary1.IService1 to a separate interface
that type ClassLibrary1.IService1 implements.
Description:
An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and
where it originated in the code.
Exception Details:
System.InvalidOperationException: The service class of type
Castle.Proxies.IService1Proxy both defines a ServiceContract and inherits a
ServiceContract from type ClassLibrary1.IService1. Contract inheritance can only
be used among interface types. ÿIf a class is marked with
ServiceContractAttribute, it must be the only type in the hierarchy with
ServiceContractAttribute. ÿConsider moving the ServiceContractAttribute on type
ClassLibrary1.IService1 to a separate interface that type
ClassLibrary1.IService1 implements.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: The service class of type Castle.Proxies.IService1Proxy both defines a ServiceContract and inherits a ServiceContract from type ClassLibrary1.IService1. Contract inheritance can only be used among interface types. If a class is marked with ServiceContractAttribute, it must be the only type in the hierarchy with ServiceContractAttribute. Consider moving the ServiceContractAttribute on type ClassLibrary1.IService1 to a separate interface that type ClassLibrary1.IService1 implements.] System.ServiceModel.Description.ServiceReflector.GetInterfaces(Type service) +16386111 System.ServiceModel.ServiceHost.CreateDescription(IDictionary`2& implementedContracts) +295 System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses) +160 System.ServiceModel.ServiceHost..ctor(Object singletonInstance, Uri[] baseAddresses) +302 Autofac.Integration.Wcf.AutofacServiceHostFactory.CreateSingletonServiceHost(Object singletonInstance, Uri[] baseAddresses) +56 Autofac.Integration.Wcf.AutofacHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +239 System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +1928 System.ServiceModel.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity) +66 System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +757[ServiceActivationException: The service '/Service1.svc' cannot be activated due to an exception during compilation. The exception message is: The service class of type Castle.Proxies.IService1Proxy both defines a ServiceContract and inherits a ServiceContract from type ClassLibrary1.IService1. Contract inheritance can only be used among interface types. If a class is marked with ServiceContractAttribute, it must be the only type in the hierarchy with ServiceContractAttribute. Consider moving the ServiceContractAttribute on type ClassLibrary1.IService1 to a separate interface that type ClassLibrary1.IService1 implements..] System.Runtime.AsyncResult.End(IAsyncResult result) +611 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +239 System.Web.CallHandlerExecutionStep.InvokeEndHandler(IAsyncResult ar) +231 System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +172
Version Information:ÿMicrosoft .NET Framework Version:4.0.30319; ASP.NET
Version:4.8.4494.0 --.
Put the exception with stack trace here.
Dependency Versions
Additional Info
The text was updated successfully, but these errors were encountered:
Describe the Bug
Autofac WCF service doesn't initialize in Singleton mode if Autofac Interceptors are also configured.
Steps to Reproduce
Sample WCF service project is provided in below github repo. Just set the WCFService as startup project and Service1.svc as Start page and run, you will get the error as
https://github.com/devlic1/AutofacWCFTest
Error is coming when we are configuring the service as SingleInstance and Enabling the Interceptors at the same time. If we remove anyone from these, then service works fine. i.e. If we remove the Interceptor OR we remove the SingleInstance (and remove InstanceContextMode from ServiceBehavior), then Service works fine
Expected Behavior
Service should run fine with both configurations i.e. Interceptors with SingleInstance service
Exception with Stack Trace
<TITLE>The service class of type Castle.Proxies.IService1Proxy both defines a ServiceContract and inherits a ServiceContract from type ClassLibrary1.IService1. Contract inheritance can only be used among interface types. ÿIf a class is marked with ServiceContractAttribute, it must be the only type in the hierarchy with ServiceContractAttribute. ÿConsider moving the ServiceContractAttribute on type ClassLibrary1.IService1 to a separate interface that type ClassLibrary1.IService1 implements.</TITLE> Error: Cannot obtain Metadata from http://localhost:60837/Service1.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: http://localhost:60837/Service1.svc Metadata contains a reference that cannot be resolved: 'http://localhost:60837/Service1.svc'. The requested service, 'http://localhost:60837/Service1.svc' could not be activated. See the server's diagnostic trace logs for more information.HTTP GET Error URI: http://localhost:60837/Service1.svc There was an error downloading 'http://localhost:60837/Service1.svc'. The request failed with the error message:-- <STYLE> body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:pointer; } @media screen and (max-width: 639px) { pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; } } @media screen and (max-width: 479px) { pre { width: 280px; } } </STYLE>Server Error in '/' Application.
The service class of type Castle.Proxies.IService1Proxy both defines a ServiceContract and inherits a ServiceContract from type ClassLibrary1.IService1. Contract inheritance can only be used among interface types. ÿIf a class is marked with ServiceContractAttribute, it must be the only type in the hierarchy with ServiceContractAttribute. ÿConsider moving the ServiceContractAttribute on type ClassLibrary1.IService1 to a separate interface that type ClassLibrary1.IService1 implements.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.InvalidOperationException: The service class of type Castle.Proxies.IService1Proxy both defines a ServiceContract and inherits a ServiceContract from type ClassLibrary1.IService1. Contract inheritance can only be used among interface types. ÿIf a class is marked with ServiceContractAttribute, it must be the only type in the hierarchy with ServiceContractAttribute. ÿConsider moving the ServiceContractAttribute on type ClassLibrary1.IService1 to a separate interface that type ClassLibrary1.IService1 implements.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
Version Information:ÿMicrosoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4494.0 --.
Dependency Versions
Additional Info
The text was updated successfully, but these errors were encountered: