Click here to Skip to main content
12,949,858 members (85,615 online)
Rate this:
 
Please Sign up or sign in to vote.
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
       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 13-Jul-12 7:22am
Updated 13-Jul-12 7:56am
Mehdi Gholam335.9K
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)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 5,749
CHill60 3,380
Maciej Los 2,953
Jochen Arndt 1,935
ppolymorphe 1,820


Advertise | Privacy | Mobile
Web02 | 2.8.170524.1 | Last Updated 13 Jul 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100