question

AnshulMittal-2591 avatar image
0 Votes"
AnshulMittal-2591 asked AnshulMittal-2591 edited

WCF service operation did not recieve a reply within configured timeout + sortedlist

I have a WCF service and a windows form client which connects to WCF service. The ServiceContract and OperationContract is as shown below.

[ServiceContract]
public interface IDInterface
{
[OperationContract]
string GetSystemName();

[OperationContract]
string Ping();

[OperationContract]
SortedList GetSystemVersion();

[OperationContract]
SortedList GetInfo();
}

From my windows forms client when i call GetSystemName() and Ping() it works fine. But when i call GetSystemVersion() with return type 'SortedList' the call doesnt even go to service. I get error "This request operation did not recieve reply within the configured timeout (00:01:00).

I migrated code from .NET remoting to WCF and in .NET remoting the time for executing GetSystemVersion() was instantaneous (not even 1 second).

Is it something related to SortedList? Do i need to configure something to work WCF service with return type SortedList?

This is critical to resolve. Immediate help will be appreciated.

dotnet-csharpwindows-wcf
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

How do you know it didn't blow up? The WCF service doesn't return an exception automatically back to the client.

https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-step-into-wcf-services?view=vs-2019


0 Votes 0 ·

This is not a single time error. Everytime i execute GetSystemVersion OperationContract i get the same exception. And everytime i execute GetSystemName() and Ping() it works absolutely fine.

Also the time for executing GetSystemVersion was instantaneous (not even 1 second) when the code was in .NET remoting.

GetSystemVersion creates objects of a different dll and calls its functions and it was working absolutely fine in .NET remoting.

The first line of GetSystemVersion is trace which is never executed while using WCF because i dont see it in traces. In .Net remoting it was tracing everything from GetSystemVersion.

0 Votes 0 ·

I have identified root cause from the traces and replicated the issue in a sample code. It is because of a complex SortedList i am returning. In .Net remoting i had no such issue. Can anyone please explain how i can resolve this issue (i.e. able to return sorted list of this type?).

Replicated sample program :
[OperationContract]
SortedList GetSortedList();

     public SortedList GetSortedList()
     {
         SortedList xmlString = new SortedList();
         SortedList VersionInfo = new SortedList();
         string[] _versionInfo = new string[2];
         _versionInfo.SetValue("Anshul", 0);
         _versionInfo.SetValue("Mittal", 1);
         VersionInfo.Add("Details", _versionInfo);

         xmlString.Add("1", VersionInfo);
         //xmlString.Add("2", "Mittal");
         return xmlString;
     }
0 Votes 0 ·

There was an error while trying to serialize parameter http://tempuri.org/:GetSystemVersionResult. The InnerException message was 'Type 'System.String[]' with data contract name 'ArrayOfstring:http://schemas.microsoft.com/2003/10/Serialization/Arrays' is not expected. Consider using a DataContractResolver if you are using DataContractSerializer or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to the serializer.'. Please see InnerException for more details.

0 Votes 0 ·

1 Answer

AnshulMittal-2591 avatar image
0 Votes"
AnshulMittal-2591 answered

Add [ServiceKnownType(typeof(string[]))] attribute to interface.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.