none
hi, i am getting this error: An exception was thrown in a call to a WSDL export extension: System.ServiceModel.Description.DataContractSerializerOperationBehavior contract: http://tempuri.org/:IApplicationService RRS feed

  • Question

  • Greetings,

    i am getting this error:

    System.InvalidOperationException: An exception was thrown in a call to a WSDL export extension: System.ServiceModel.Description.DataContractSerializerOperationBehavior
     contract: http://tempuri.org/:IApplicationService

    This what my code looks like

    IApplicationService.cs

    [ServiceContract(ProtectionLevel=ProtectionLevel.EncryptAndSign)]
        public interface IApplicationService
        {
            [OperationContract]
            [TransactionFlow(TransactionFlowOption.Allowed)]
            Applications AddApplication(Applications application);
    
            [OperationContract]
            [TransactionFlow(TransactionFlowOption.Allowed)]
            Applications UpdateApplication(Applications application);
    
            [OperationContract]
            [TransactionFlow(TransactionFlowOption.Allowed)]
            void DeleteApplication(int applicationId);
    
            [OperationContract]
            [FaultContract(typeof(NotFoundException))]
            Applications GetApplication(int applicationId);
    
            [OperationContract]
            Applications[] GetAllApplications();
    
            [OperationContract]
            UserApplicationsData[] GetApplicationsCategoriesByUser(string userStateId);
    
            [OperationContract]
            bool ApplicationExists(string applicationsName);
    
        }


    My Application.cs class is as followed

    [DataContract]
        public class Applications : EntityBase, IIdentifiableEntity
        {
            [DataMember(IsRequired = true, EmitDefaultValue = true)]
            public int ApplicationsId { get; set; }
    
            [DataMember(IsRequired = true, EmitDefaultValue = true)]
            public int ApplicationsCategorieId { get; set; }
    
            [DataMember]
            public string ApplicationsName { get; set; }
    
            [DataMember]
            public string ApplicationsDescription { get; set; }
    
            [DataMember]
            public string ApplicationsControllerName { get; set; }
    
            [DataMember]
            public string ApplicationsDefaultActionName { get; set; }
    
            [DataMember]
            public string ApplicationsAdminActionName { get; set; }
    
            [DataMember]
            public DateTime CreatedDate { get; set; }
    
            [DataMember]
            public string CreatedBy { get; set; }
    
            [DataMember]
            public DateTime LastModifiedDate { get; set; }
    
            [DataMember]
            public string LastModifiedBy { get; set; }
    
            [DataMember]
            public bool IsActive { get; set; }
    
            #region IIdentifiableEntity Members
    
            public int EntityId
            {
                get
                {
                    return ApplicationsId;
                }
                set
                {
                    ApplicationsId = value;
                }
            }
    
            #endregion
        }


    My service host web.config

    <system.serviceModel>
        <services> 
          <service name="ApplicationsManager">
            <endpoint address="net.tcp://someIP:808/ApplicationService"
                      binding="netTcpBinding"
                      contract="IApplicationService" />
            <endpoint address="mex"
                      binding="mexHttpBinding"
                      contract="IMetadataExchange" />
          </service>
        </services>
        <bindings>
          <netTcpBinding>
            <binding maxReceivedMessageSize="2000000" transactionFlow="true">
              <reliableSession enabled="true"/>
              <security mode="Transport">
                <transport clientCredentialType="Windows" />
              </security>
            </binding>
          </netTcpBinding>
        </bindings>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <serviceCredentials useIdentityConfiguration="true"/>
              <serviceAuthorization principalPermissionMode="Always"/>
              <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
              <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="true"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <protocolMapping>
            <add binding="basicHttpsBinding" scheme="https" />
        </protocolMapping>    
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      </system.serviceModel>


    My EntityBase.cs

    [DataContract]
        public abstract class EntityBase : IExtensibleDataObject
        {
            #region IExtensibleDataObject Members
    
            public ExtensionDataObject ExtensionData { get; set; }
    
            #endregion
        }


    My IIdentifiableEntity.cs Interface

     public interface IIdentifiableEntity
        {
            int EntityId
            {
                get;
                set;
            }
        }

    Any help/hints will be greatly appreciated.

    _Ousmane



    • Edited by DofLeFou Wednesday, October 16, 2013 5:42 PM
    Wednesday, October 16, 2013 5:41 PM

Answers

  • I found my issue

    [FaultContract(typeof(NotFoundException))]

    I need to mark my NotFoundException class as SerialzableAttribute.

    [SerializableAttribute]
        public class NotFoundException : ApplicationException
        {
            public NotFoundException(string message)
                : base(message)
            {
            }
    
            public NotFoundException(string message, Exception exception)
                : base(message, exception)
            {
            }
        }

    _Ousmane

    • Marked as answer by DofLeFou Saturday, October 19, 2013 6:52 PM
    Saturday, October 19, 2013 6:52 PM

All replies

  • Can you post the stack trace text property  from the exception?  it would help isolate the issue.

    jdweng

    Wednesday, October 16, 2013 6:18 PM
  • The service encountered an error.
    
    An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
    System.InvalidOperationException: An exception was thrown in a call to a WSDL export extension: System.ServiceModel.Description.DataContractSerializerOperationBehavior
     contract: http://tempuri.org/:IApplicationService ----> System.Runtime.Serialization.InvalidDataContractException: Type 'intranet.core.common.Exceptions.NotFoundException' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.  If the type is a collection, consider marking it with the CollectionDataContractAttribute.  See the Microsoft .NET Framework documentation for other supported types.
       at System.Runtime.Serialization.DataContract.DataContractCriticalHelper.ThrowInvalidDataContractException(String message, Type type)
       at System.Runtime.Serialization.DataContract.DataContractCriticalHelper.CreateDataContract(Int32 id, RuntimeTypeHandle typeHandle, Type type)
       at System.Runtime.Serialization.DataContract.GetDataContract(Int32 id, RuntimeTypeHandle typeHandle, SerializationMode mode)
       at System.Runtime.Serialization.DataContractSet.Add(Type type)
       at System.Runtime.Serialization.XsdDataContractExporter.Export(Type type)
       at System.ServiceModel.Description.MessageContractExporter.ExportType(Type type, String partName, String operationName, XmlSchemaType& xsdType)
       at System.ServiceModel.Description.MessageContractExporter.ExportFaultElement(FaultDescription fault)
       at System.ServiceModel.Description.MessageContractExporter.ExportFault(FaultDescription fault)
       at System.ServiceModel.Description.MessageContractExporter.ExportFaults(Object state)
       at System.ServiceModel.Description.MessageContractExporter.ExportMessageContract()
       at System.ServiceModel.Description.WsdlExporter.CallExtension(WsdlContractConversionContext contractContext, IWsdlExportExtension extension)
       --- End of inner ExceptionDetail stack trace ---
       at System.ServiceModel.Description.WsdlExporter.CallExtension(WsdlContractConversionContext contractContext, IWsdlExportExtension extension)
       at System.ServiceModel.Description.WsdlExporter.CallExportContract(WsdlContractConversionContext contractContext)
       at System.ServiceModel.Description.WsdlExporter.ExportContract(ContractDescription contract)
       at System.ServiceModel.Description.WsdlExporter.ExportEndpoint(ServiceEndpoint endpoint, XmlQualifiedName wsdlServiceQName, BindingParameterCollection bindingParameters)
       at System.ServiceModel.Description.WsdlExporter.ExportEndpoints(IEnumerable`1 endpoints, XmlQualifiedName wsdlServiceQName, BindingParameterCollection bindingParameters)
       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)
    Thank you
    • Edited by DofLeFou Wednesday, October 16, 2013 6:29 PM
    Wednesday, October 16, 2013 6:29 PM
  • I think the problem is with one of th etwo properties below.  for a test try to make both of them just "DataMember" without the default value and the isrequeire like the other properties.  If this works check the data that is received and see if you are getting a value for each of th etwo properties.  Then try to restore each of the properties one at a time and se what happens.

    The trace stack seems to be indicating a problem with a "Int32 id" and these are the only two integer properties.

    I also noticed that you have an interface for the AppicationsId but not the ApplicationsCategorieId.  Not sure why you are handling the two different.

           [DataMember(IsRequired = true, EmitDefaultValue = true)]
            public int ApplicationsId { get; set; }
            [DataMember(IsRequired = true, EmitDefaultValue = true)]
            public int ApplicationsCategorieId { get; set; }


    jdweng

    Wednesday, October 16, 2013 8:58 PM
  • Jdweng,

    I gave that a try as below, but still same issue

    [DataContract]
        public class Applications : EntityBase, IIdentifiableEntity
        {
            [DataMember]
            public int ApplicationsId { get; set; }
    
            [DataMember]
            public int ApplicationsCategorieId { get; set; }
    
            [DataMember]
            public string ApplicationsName { get; set; }
    
            [DataMember]
            public string ApplicationsDescription { get; set; }
    
            [DataMember]
            public string ApplicationsControllerName { get; set; }
    
            [DataMember]
            public string ApplicationsDefaultActionName { get; set; }
    
            [DataMember]
            public string ApplicationsAdminActionName { get; set; }
    
            [DataMember]
            public DateTime CreatedDate { get; set; }
    
            [DataMember]
            public string CreatedBy { get; set; }
    
            [DataMember]
            public DateTime LastModifiedDate { get; set; }
    
            [DataMember]
            public string LastModifiedBy { get; set; }
    
            [DataMember]
            public bool IsActive { get; set; }
    
            #region IIdentifiableEntity Members
    
            public int EntityId
            {
                get
                {
                    return ApplicationsId;
                }
                set
                {
                    ApplicationsId = value;
                }
            }
    
            #endregion
        }


    Could it be the following int?

     #region IIdentifiableEntity Members
    
            public int EntityId
            {
                get
                {
                    return ApplicationsId;
                }
                set
                {
                    ApplicationsId = value;
                }
            }
    
            #endregion

    I have not decorated this with [DataMember] my assumption is it should ignore it.

    _Ousmane

    Wednesday, October 16, 2013 9:07 PM
  • did yo uget exactly the same stack trace error? I don't deal with these interface very often.  I responded only to get the stack trace because I knew somebody more familar with these interfaces would need the stack trace to help determine the cause of the issue.

    jdweng

    Wednesday, October 16, 2013 9:21 PM
  • Yes exactly the same same stack error.

    _Ousmane

    Wednesday, October 16, 2013 9:25 PM
  • I have tried hosting it using Windows service and it works just perfect. The error only occurs while hosting it via IIS.

    Any Ideas?

    _Ousmane

    Thursday, October 17, 2013 12:46 AM
  • amke sure you are receiving data.  The connection may not be completing.  when I was looking at the stack trace it seems to indicate that the first property was bad, but I couldn't tell if the the first property was bad or the entire message was bad.  Try to capture the data that is received.  It may be the conection isn't completing.    It is posible that the data is packed and you need to unpack the data stream. It also may be the receive stream is packed, encrypted, a certificate is missing, or a cookie is expired.

    If the data is bad, I would consider using a sniffer like fiddler or wireshark to capture the IP mesages to get a clue at the root cause of the problem.


    jdweng

    Thursday, October 17, 2013 8:28 AM
  • I found my issue

    [FaultContract(typeof(NotFoundException))]

    I need to mark my NotFoundException class as SerialzableAttribute.

    [SerializableAttribute]
        public class NotFoundException : ApplicationException
        {
            public NotFoundException(string message)
                : base(message)
            {
            }
    
            public NotFoundException(string message, Exception exception)
                : base(message, exception)
            {
            }
        }

    _Ousmane

    • Marked as answer by DofLeFou Saturday, October 19, 2013 6:52 PM
    Saturday, October 19, 2013 6:52 PM