Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have PCS application which is having DAL and Modal layer which is done in MVC3 architecture.Need to create the WCF service, can i use PCS dll in WCF for accessing DAL and modal objects.I tried
C#
public List<pcsmvc.country> GetCountry()
 {

     List<pcsmvc.country> lst = new List<pcsmvc.country>();
     lst[0].CountryName = "India";
    return lst;
 }

WCF Test Client says
"GetCountry operation  is not supported because it uses the type PCSMVC.Country[]"
,please help me on this.
Posted
Updated 13-Jul-12 7:56am
v2
Comments
Trak4Net 13-Jul-12 15:37pm    
From your error message it looks like PCSMVC.Country[] is an array. It looks like you are trying to use it as if it is an object. What is the definition for PCSMVC.Country ? Is it a collection or a single object with properties.

Also, you initialize your list and try accessing first object in list when you haven't added anything to the list yet, I would imagine if it reached that line of code you would get an index out of range error, since the list contains no items.


public List<pcsmvc.country> GetCountry()
{

List<pcsmvc.country> lst = new List<pcsmvc.country>();
//should add an object of pcsmvc.country (can initialize properties also)
lst.Add(new pcsmvc.country() { CountryName = "India" });
return lst;
}
or you can do it this way...


public List<pcsmvc.country> GetCountry()
{

List<pcsmvc.country> lst = new List<pcsmvc.country>();
//should add an object of pcsmvc.country
lst.Add(new pcsmvc.country());
//now the list contains the object and you can access it
lst[0].CountryName = "India";
return lst;
}
chkrvrthy 16-Jul-12 9:10am    
Thanqu, I got it.

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