Click here to Skip to main content
16,016,489 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear All,

I have an exising dll with members as:

C#
public class ArrTestObj
{
   private string _str1 = "0";
   private Object[] ArListResponse;
   public string str1{ get { return _str1; } set { _str1 = value; } }
   public Object[] ArrUpdates { get { return ArListResponse; } set { Object[] val = value; ArListResponse = val; } 
}


I want to send this Class object to Web service client.

I have tried to created a Datacontract for this and anothe extended class inheriting the Datacontract class.

CSS
[DataContract]
public class ArrTestObj
{
 
    [DataMember]
    public string str1{ get; set; }

    [DataMember]
    public Object[] ArrUpdates { get; set; }
    
}


But there was no luck. I had to send the data by extending all the objects in Object Array.
Posted
Updated 24-Jan-12 20:38pm
v3
Comments
Sergey Alexandrovich Kryukov 25-Jan-12 2:19am    
"No luck" is not a valid description of the issue. What happens, exactly?
Why using Object type, not some concrete types? Do you really need public members (Data Contract does not require it)?
--SA
jigi_chavan 25-Jan-12 2:31am    
Actually, after using concrete types it has worked.
In existing Business dll, data from database are stored in an array of Objects and sent back to another layer.
We are trying to use existing Business dll and functionality using WCF.
Instead of Object[] now we are using another DataContract with definition from Business dll.

I was just hoping that Object[] can be used in DataMember.
[no name] 25-Jan-12 10:31am    
And how do you expect serialization and deserialization to work when you call the service? This just proves how bad an approach working around type safety by using object arrays really is. Did you ever consider refactoring that library or, if refactoring is not possible, wrapping it up in a more adequate way?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900