Bonjour,

Voilà j'ai créé un projet WCF (vb.NET) tout bête en suivant un tuto qui renvoie la valeur en Dollars d'une valeur en Euros.

J'ai développé un client Silverlight (vb.NET) avec appel asynchrone pour recupérer la valeur sous un click bouton :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
 
Partial
Public Class Page 
Inherits UserControl 
Public Sub New() 
InitializeComponent()
End Sub 
Private Sub appelService(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) 
Dim val As Decimal 
' Dim pat As New PageAsyncTask(AddressOf BeginProductRetrieveAsync, AddressOf EndProductRetrieveAsync, Nothing, Nothing) 
val = 100
MessageBox.Show(
"Clicked. Tentative d'appel du service") 
Dim client As ServiceTest.ServiceDevClient 
client = 
New ServiceTest.ServiceDevClient() 
MessageBox.Show(
"Avant appel asynchrone") 
AddHandler client.EuroToUsDollarsCompleted, AddressOf EuroToUsDollarsCallback 
client.EuroToUsDollarsAsync(val)
MessageBox.Show(
"Apres appel asynchrone") 
End Sub 
Private Shared Sub EuroToUsDollarsCallback(ByVal sender As Object, ByVal e As ServiceTest.EuroToUsDollarsCompletedEventArgs) 
Try 
MessageBox.Show(
"reponse : " & e.Result) 
Console.WriteLine(
"Add Result: {0}", e.Result) 
Catch ex As Exception 
MessageBox.Show(
"Exception dans eurotousdollarscallback " & ex.Message) 
End Try 
 
End Sub 
Public Event EuroToUsDollarsCompleted As System.EventHandler(Of ServiceTest.EuroToUsDollarsCompletedEventArgs) 
<System.Diagnostics.DebuggerStepThroughAttribute(), _
System.CodeDom.Compiler.GeneratedCodeAttribute(
"System.ServiceModel", "3.0.0.0")> _ 
Partial Public Class EuroToUsDollarsCompletedEventArgs 
Inherits System.ComponentModel.AsyncCompletedEventArgs 
Private results() As Object 
Public Sub New(ByVal results() As Object, ByVal exception As System.Exception, ByVal cancelled As Boolean, ByVal userState As Object) 
MyBase.New(exception, cancelled, userState) 
Me.results = results 
End Sub 
Public ReadOnly Property Result() As Double 
Get 
MyBase.RaiseExceptionIfNecessary() 
Return CType(Me.results(0), Double) 
End Get 
End Property 
End Class 
End
Class
J'ai même essayé en C# :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 
using
System; 
using
System.Collections.Generic; 
using
System.Linq; 
using
System.Net; 
using
System.Windows; 
using
System.Windows.Controls; 
using
System.Windows.Documents; 
using
System.Windows.Input; 
using
System.Windows.Media; 
using
System.Windows.Media.Animation; 
using
System.Windows.Shapes; 
namespace
Essai 
{
public partial class Page : UserControl 
{
public Page() 
{
InitializeComponent();
}
private void appelService(object sender, RoutedEventArgs e) 
{
ServiceTest.
ServiceDevClient client = new ServiceTest.ServiceDevClient("basicHttpBinding_ServiceDevClient"); 
client.EuroToUsDollarsCompleted += 
new EventHandler<ServiceTest.EuroToUsDollarsCompletedEventArgs>(client_EuroToUsDollarsCompleted); 
client.EuroToUsDollarsAsync(
Convert.ToDecimal(valeurEntree.Text)); 
}
void client_EuroToUsDollarsCompleted(object sender, ServiceTest.EuroToUsDollarsCompletedEventArgs e) 
{
decimal result = e.Result; 
this.valeurCalculeeService.Text = result.ToString(); 
MessageBox.Show(" fin appel "); 
MessageBox.Show(result.ToString()); 
}
}
}
Mais rien n'y fait je tombe toujours sur la même erreur au moment où je clique sur le bouton :


J'ai même essayé d'ajouter crossdomain.xml et clientaccesspolicy.xml mais ça ne change rien.

Quelqu'un a une idée ?

Merci d'avance !