Click here to Skip to main content
16,021,560 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: RadioButton DataBinding, without code-behind Pin
ausadmin22-Oct-09 9:36
ausadmin22-Oct-09 9:36 
GeneralRe: RadioButton DataBinding, without code-behind Pin
hhrafn23-Oct-09 5:15
hhrafn23-Oct-09 5:15 
QuestionC# Source code to draw the real time graph using Silverlight Pin
Rameshwar Yadav21-Oct-09 2:34
Rameshwar Yadav21-Oct-09 2:34 
QuestionBinding to UserControl's inner item's property without code-behind Pin
hhrafn19-Oct-09 23:43
hhrafn19-Oct-09 23:43 
Questionhow to design page navigation window form using back and next button. Pin
@nisha 2n19-Oct-09 21:43
@nisha 2n19-Oct-09 21:43 
Questionhow to design page navigation window form using back & next button Pin
@nisha 2n19-Oct-09 21:41
@nisha 2n19-Oct-09 21:41 
AnswerRe: how to design page navigation window form using back & next button Pin
Mark Salsbery20-Oct-09 6:27
Mark Salsbery20-Oct-09 6:27 
QuestionError passing List as a parameter to web service Pin
CBenac19-Oct-09 9:17
CBenac19-Oct-09 9:17 
Error passing List as a parameter to web service

This is my second post on the same subject, in an attempt to solve the same problem. I hope this time I've supplied enough and correct information. Given a basic service, it is possible to return a List from the web service using the GetList() method but the compiler gives an error when trying to send the list as a parameter in the SendList() method. Please check the code bellow. I've revised it.

The error is on line # 88 (The compiler error description is at the end of the source code)

Note: I've configured the ServiceReference to return System.Collections.Generic.List although I've tested all possible combinations.

1 namespace SilverlightApplication1.Web
2 {
3 [ServiceContract(Namespace = "")]
4 [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
5 public class Service1
6 {
7 [OperationContract]
8 public List GetList()
9 {
10 // Add your operation implementation here
11 List myList = new List();
12 myList.Add(new People() { name = "AAA", age = 42 });
13 return myList;
14 }
15 [OperationContract]
16 public string SendList(List myList)
17 {
18 return myList[0].name;
19 }
20 }
21
22 public class People
23 {
24 public string name;
25 public int age;
26 }
27 }
28
29
30 "SilverlightApplication1.Home"
31 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
32 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33 xmlnsBig Grin | :-D ="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
34 xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
35 mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
36 Title="Home"
37 Style="{StaticResource PageStyle}">
38
39 <grid x:name="LayoutRoot" &gt;
40="" <scrollviewer="" style="{StaticResource PageScrollViewerStyle}" &gt;
41=""
42="" <stackpanel="" &gt;
43=""
44="" <textblock=""
45="" text="Home">
46 <textblock x:name="ContentText" style="{StaticResource ContentTextStyle}"
47="" text="Home page content">
48
49
50
51
52
53
54
55
56
57
58
59
60 namespace SilverlightApplication1
61 {
62 public partial class Home : Page
63 {
64 public Home()
65 {
66 InitializeComponent();
67 }
68
69 private void btnGetList_Click(object sender, RoutedEventArgs e)
70 {
71 ServiceReference1.Service1Client proxy = new SilverlightApplication1.ServiceReference1.Service1Client();
72 proxy.GetListCompleted +=new EventHandler<silverlightapplication1.servicereference1.getlistcompletedeventargs>(proxy_GetListCompleted);
73 proxy.GetListAsync();
74 }
75 // THIS WORKS
76 void proxy_GetListCompleted(object sender, SilverlightApplication1.ServiceReference1.GetListCompletedEventArgs e)
77 {
78 MessageBox.Show(e.Result[0].name + " " + e.Result[0].age.ToString());
79 }
80
81 private void btnSendList_Click(object sender, RoutedEventArgs e)
82 {
83 List<people> myList = new List<people>();
84 myList.Add(new People() { name = "AAA", age = 42 });
85
86 ServiceReference1.Service1Client proxy2 = new SilverlightApplication1.ServiceReference1.Service1Client();
87 proxy2.SendListCompleted += new EventHandler(proxy2_SendListCompleted);
88 proxy2.SendListAsync(myList); // COMPILE ERROR SEE DESCRIPTION BELLOW
89 }
90
91 void proxy2_SendListCompleted(object sender, SilverlightApplication1.ServiceReference1.SendListCompletedEventArgs e)
92 {
93 throw new NotImplementedException();
94 }
95 }
96
97 public class People
98 {
99 public string name;
100 public int age;
101 }
102 }
103

Error 2 Argument '1': cannot convert from 'System.Collections.Generic.List<silverlightapplication1.people>' to 'System.Collections.Generic.List<silverlightapplication1.servicereference1.people>' e:\SilverlightApplication1\Views\Home.xaml.cs 42 34 SilverlightApplication1

Error 1 The best overloaded method match for 'SilverlightApplication1.ServiceReference1.Service1Client.SendListAsync(System.Collections.Generic.List<silverlightapplication1.servicereference1.people>)' has some invalid arguments e:\SilverlightApplication1\Views\Home.xaml.cs 42 13 SilverlightApplication1
AnswerRe: Error passing List as a parameter to web service Pin
Nigel Ferrissey19-Oct-09 10:38
Nigel Ferrissey19-Oct-09 10:38 
AnswerRe: Error passing List as a parameter to web service Pin
Mark Salsbery19-Oct-09 11:33
Mark Salsbery19-Oct-09 11:33 
GeneralRe: Error passing List as a parameter to web service Pin
CBenac19-Oct-09 12:47
CBenac19-Oct-09 12:47 
QuestionWebcam Capturing and Broadcasting To Multiple And Receiving Requests To See Webcam ---All Via Peep To Peer Communication Pin
deepbhullar19-Oct-09 2:17
deepbhullar19-Oct-09 2:17 
QuestionO.o help hehe beginner [some what have an answer] Pin
nerra19-Oct-09 0:01
nerra19-Oct-09 0:01 
AnswerRe: O.o help hehe beginner Pin
Richard MacCutchan19-Oct-09 0:04
mveRichard MacCutchan19-Oct-09 0:04 
GeneralRe: O.o help hehe beginner [modified] Pin
nerra19-Oct-09 0:09
nerra19-Oct-09 0:09 
GeneralRe: O.o help hehe beginner Pin
Richard MacCutchan19-Oct-09 0:32
mveRichard MacCutchan19-Oct-09 0:32 
GeneralRe: O.o help hehe beginner Pin
nerra19-Oct-09 0:54
nerra19-Oct-09 0:54 
GeneralRe: O.o help hehe beginner Pin
Richard MacCutchan19-Oct-09 1:22
mveRichard MacCutchan19-Oct-09 1:22 
GeneralRe: O.o help hehe beginner Pin
nerra19-Oct-09 1:33
nerra19-Oct-09 1:33 
GeneralRe: O.o help hehe beginner Pin
Mark Salsbery19-Oct-09 7:10
Mark Salsbery19-Oct-09 7:10 
GeneralRe: O.o help hehe beginner Pin
nerra21-Oct-09 2:53
nerra21-Oct-09 2:53 
GeneralRe: O.o help hehe beginner Pin
Richard MacCutchan21-Oct-09 3:03
mveRichard MacCutchan21-Oct-09 3:03 
GeneralRe: O.o help hehe beginner Pin
nerra23-Oct-09 18:44
nerra23-Oct-09 18:44 
GeneralRe: O.o help hehe beginner Pin
Richard MacCutchan23-Oct-09 21:27
mveRichard MacCutchan23-Oct-09 21:27 
AnswerRe: O.o help hehe beginner [some what have an answer] Pin
Christian Graus20-Oct-09 20:35
protectorChristian Graus20-Oct-09 20:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.