Click here to Skip to main content
11,642,855 members (76,346 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET WCF C#4.0 MVC
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
Edited 13-Jul-12 7:56am
(no name)282.8K
v2
Comments
Trak4Net at 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 at 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
0 DamithSL 258
1 Sergey Alexandrovich Kryukov 230
2 jyo.net 180
3 OriginalGriff 170
4 Afzaal Ahmad Zeeshan 155
0 Mika Wendelius 485
1 DamithSL 457
2 OriginalGriff 365
3 Afzaal Ahmad Zeeshan 258
4 Sergey Alexandrovich Kryukov 254


Advertise | Privacy | Mobile
Web02 | 2.8.150731.1 | Last Updated 13 Jul 2012
Copyright © CodeProject, 1999-2015
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