URGENT: System.InvalidOperationException: System.Object& cannot be serialized because it does not have a parameterless constructor.

May 19, 2010 at 2:26 PM

Hi All,

I'm trying to use WcfUnit.exe to generate unit test cases for my WCF service in order to load test them. I'm using the command line utility WcfUnit.exe to generate the unit test code. Everything goes fine except the following error,

C:\LoadTestProject> "C:\Program Files\WcfUnit\WcfUnit.exe" CompileTimeScenario "C:\logs\WCFClient.svclog" SampleConfig.xml

WCF Load Test Generator Version 3.0.0.0

Parsed message with action http://tempuri.org/IService/GetUserData [OK]

Unhandled Exception: System.InvalidOperationException: System.Object& cannot be
serialized because it does not have a parameterless constructor.
   at System.Xml.Serialization.TypeDesc.CheckSupported()
   at System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo sourc
e, Boolean directReference, Boolean throwOnError)
   at System.Xml.Serialization.ModelScope.GetTypeModel(Type type, Boolean direct
Reference)
   at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(Type type
, XmlRootAttribute root, String defaultNamespace)
   at System.Xml.Serialization.XmlSerializer..ctor(Type type, XmlAttributeOverri
des overrides, Type[] extraTypes, XmlRootAttribute root, String defaultNamespace
, String location, Evidence evidence)
   at System.Xml.Serialization.XmlSerializer..ctor(Type type, XmlRootAttribute r
oot)
   at Microsoft.WcfUnit.Library.Deserializer.DeserializeXmlSerializerInputParame
ters(MessageBuffer messageBuffer, String proxyNamespace, ParameterInfo[] paramet
ers)
   at Microsoft.WcfUnit.Library.Deserializer.DeserializeInputParameters(MessageB
uffer messageBuffer, MethodBase contractMethod)
   at Microsoft.WcfUnit.Library.TraceFileProcessor.ProcessTraceFile(String scena
rioName, String traceFileName, Stream timedCommentsFile, WcfUnitConfiguration co
nfiguration, String mainFileName, String stubFileName)
   at Microsoft.WcfUnit.Library.TraceFileProcessor.ProcessTraceFile(String scena
rioName, String traceFile, Stream timedCommentsFile, WcfUnitConfiguration config
uration)
   at Microsoft.WcfUnit.Program.Main(String[] args)

GetUserData OperationContract Definition is as follows,

   <OperationContract()> _
    Function GetUserData(ByVal sUserID, ByVal sDomain, ByRef sError) As System.Data.DataSet

I'm suspecting the error could be because the 3rd parameter sError being of reference type?

Please help me solve this issue.

Thanks,
Prasanna

Coordinator
May 21, 2010 at 8:34 AM

Sorry it took a while to get back to you, I have limited time these days and I wanted to try to repro your problem.

When I failed to repro the problem I looked more closely at the stack trace you posted and I can see that the tool has recognised the operation as requiring the use of the Xml Serializer rather than the Data Contract serializer. The tool does not support out and ref parameters with the XmlSerializer. Perhaps you could post more details of the contract?

Thanks

Rob

May 21, 2010 at 9:50 AM

Thanks Rob for your reply.

As posted in my previous message following is the operation contract. I don't use any datacontracts but simply return a DataSet.

   <OperationContract()> _
    Function GetUserData(ByVal sUserID, ByVal sDomain, ByRef sError) As System.Data.DataSet

Service implementation class is as follows,

<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)> _
Public Class MyService
    Implements IService

Public Function GetUserData(ByVal sUserID, ByVal sDomain, ByRef sError) As System.Data.DataSet Implements IService.GetUserData
 ...
        Dim rsDataSet As New Data.DataSet
        Try
 ...
 Fetch Dataset from DB and populate reDataSet
        Catch ex As Exception
        End Try
        Return rsDataSet
    End Function

I configured the Message tracing for the WCF service on the client side and been trying to use the svclog trace file to generate the unit test code when i hit this issue.

Regards,

Prasanna

Coordinator
May 21, 2010 at 10:19 AM

Can you post the service contract attributes?

Thanks

Rob

May 21, 2010 at 10:41 AM

Please find the service contract,

<ServiceContract()> _
Public Interface IService

   <OperationContract()> _
    Function GetUserData(ByVal sUserID, ByVal sDomain, ByRef sError) As System.Data.DataSet

End Interface

Thanks

Prasanna

Coordinator
May 21, 2010 at 11:16 AM

Are you prepared to send me the assembly containing your service contract? If so can you use the contacts page to contact me, I will then send you an email to which you can reply with the assembly. If you can, please also send me the message log file and the config file you used too.

Thanks

Rob

Coordinator
May 24, 2010 at 5:27 PM

I have been trying again to reproduce your problem, with only partial success. It would help if you could send me a full repro of the problem. What I need is a repro created using the command file version of the tool, specifically: the assembly containing the contract, the message log file (or just the bit that causes the errror) and the config file you used. Please use the Contacts page to contact me, I can then reply with an email address for you to send the repro to.

Thanks

Rob

May 25, 2010 at 3:45 AM

Apologies Rob for delayed response. Request you to kindly give me some time, as I'm checking the possibilities of getting these assemblies since they're in a secure environment pertaining to one of our client's.

Once i have them i'll definitely contact you through the contacts page.

 

Appreciate your help.

Thanks & Regards,

Prasanna

Coordinator
May 26, 2010 at 8:28 AM

If you can't get the original assemblies, can you create a simple repro instead?

Regards

Rob

May 26, 2010 at 12:10 PM

Unfortunately i'm unable to repro it as well :)

Please give me sometime while I'm waiting for the assembly to come through.

 

Regards,

Prasanna