Click here to Skip to main content
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 8:22am
Edited 13-Jul-12 8:56am
(no name)250.1K
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 OriginalGriff 8,149
1 Sergey Alexandrovich Kryukov 7,287
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,910


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