.NET Framework Bookmark and Share   
 index > Windows Communication Foundation > System.RuntimeType with data contract name is not expected!!
 

System.RuntimeType with data contract name is not expected!!

Hi guys,

I'm invoking WCF service method with following signature

Code Snippet

[ServiceContract]

[ServiceKnownType(typeof(DataScenario))]

[ServiceKnownType(typeof(PropertyDataCollection))]

[ServiceKnownType(typeof(IPDUnitDataTables))]

[ServiceKnownType(typeof(IPDDataItem))]

[ServiceKnownType(typeof(IPDDataEnumeration))]

public interface IService

{

[OperationContract]

void InvokePLC(string PlcAssemblyName, string Plc, string PlcMethod, object[] Params, out object ReturnValue);

}

I call the method as below

Code Snippet

proxy.InvokePLC("IPD.ProcessLogic.PLC.ExpressionEngine",

"PLCValidation",

"EvaluateExpressionSingle",

new object[] { _dataScenario, _propertyData, _expression, tp.FocusedDataRowView });

I have added _dataScenario, _propertyData, _expression classes as knowntype shown in the code above. But when I invoke this method I get following exception

System.ServiceModel.CommunicationException: There was an error while trying to serialize parameter http://tempuri.org/Params. The InnerException message was 'Type 'System.RuntimeType' with data contract name 'RuntimeType:http://schemas.datacontract.org/2004/07/System' is not expected.

I just stuck and don't know what to do. Does any have the solution? Am I missing something?

bhav27

When passing a collection as a DataContract it needs to be decorated with the CollectionDataContract attribute

More here: http://msdn.microsoft.com/en-us/library/aa347850.aspx

David Kreutz - MSFT
I suspect this as to do with the out parameter. Since this operation returns void anyway, why not just have it return the ReturnValue instead of using an out parameter?

Dan Rigsby

I get the same exception even if I return value rather using out param. However I get no error if I just send null as param value.

But still not clear why it gives me exception if I pass param values.

bhav27

When passing a collection as a DataContract it needs to be decorated with the CollectionDataContract attribute

More here: http://msdn.microsoft.com/en-us/library/aa347850.aspx

David Kreutz - MSFT

You can use google to search for other answers

Custom Search

More Threads

• Hosting WCF on IIS7.0 Solution
• Photo Sharing Application using WCF
• SecurityNegotiationException occurs after timeout, not immediately
• need hints for WSDL generation
• Defining the request and response in WCF service WSDL
• Performance monitoring/tuning
• SOAP Body Partial Encryption
• WCF projects
• the bindingConfiguration is ignored
• Issues in receiving serialized filestream data from WCF into C++ client