Bonjour à tous,

Dans mon application silverlight, je tombe sur cette erreur apparemment classique lorsqu'un service wcf est utilisé :
CommunicationException "NotFound" en appel distant.
J'ai cherché à droite à gauche sur le net et j'ai trouvé le pourquoi de cette erreur : http://msdn.microsoft.com/fr-fr/libr...96(VS.95).aspx

Mais voila, aprés avoir fait le nécessaire, j'ai toujours cette fameuse erreur. Voici le code ajouté dans mon service WCF :

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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System.ServiceModel; 
using System.ServiceModel.Channels; 
using System.ServiceModel.Configuration; 
using System.ServiceModel.Description; 
using System.ServiceModel.Dispatcher; 
 
namespace Test
{ 
public class SilverlightFaultBehavior : BehaviorExtensionElement, IEndpointBehavior 
{ 
#region Overriden methods 
 
public override System.Type BehaviorType 
{ 
get { return typeof(SilverlightFaultBehavior); } 
} 
 
protected override object CreateBehavior() 
{ 
return new SilverlightFaultBehavior(); 
} 
 
#endregion 
#region Methods 
 
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher) 
{ 
SilverlightFaultMessageInspector inspector = new SilverlightFaultMessageInspector(); 
endpointDispatcher.DispatchRuntime.MessageInspectors.Add(inspector); 
} 
// The following methods are stubs and not relevant. 
public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters) 
{ 
} 
public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime) 
{ 
} 
public void Validate(ServiceEndpoint endpoint) 
{ 
} 
 
#endregion 
#region Classes 
 
public class SilverlightFaultMessageInspector : IDispatchMessageInspector 
{ 
#region Methods 
 
public void BeforeSendReply(ref Message reply, object correlationState) 
{ 
if (reply.IsFault) 
{ 
HttpResponseMessageProperty property = new HttpResponseMessageProperty(); 
 
// Here the response code is changed to 200. 
property.StatusCode = System.Net.HttpStatusCode.OK; 
 
reply.Properties[HttpResponseMessageProperty.Name] = property; 
} 
} 
public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext) 
{ 
// Do nothing to the incoming message. 
return null; 
} 
 
#endregion 
} 
 
#endregion 
} 
}
Et mon web.config :

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
56
57
58
59
60
<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
<system.web> 
<compilation debug="true" targetFramework="4.0" /> 
</system.web> 
<system.serviceModel> 
<extensions> 
<behaviorExtensions> 
<add name="silverlightFaults" type="Test.SilverlightFaultBehavior, Dwss, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/> 
</behaviorExtensions> 
</extensions> 
<behaviors> 
<endpointBehaviors> 
<behavior name="SilverlightFaultBehavior"> 
<silverlightFaults /> 
</behavior> 
</endpointBehaviors> 
<serviceBehaviors> 
<behavior name="BehaviorTest"> 
<serviceMetadata httpGetEnabled="true" /> 
<serviceDebug includeExceptionDetailInFaults="true" /> 
<serviceCredentials> 
<serviceCertificate findValue="0d28a76995e85e78fe59f2ff6122626c6cf1456d" 
storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint" /> 
<userNameAuthentication userNamePasswordValidationMode="Custom" 
customUserNamePasswordValidatorType="Test.Credential, Dwss" /> 
</serviceCredentials> 
</behavior> 
</serviceBehaviors> 
</behaviors> 
<services> 
<service behaviorConfiguration="BehaviorTest" name="Test.Test"> 
<endpoint binding="wsHttpBinding" bindingConfiguration="BindingTest" 
behaviorConfiguration="SilverlightFaultBehavior" 
contract="Test.ITest"> 
<identity> 
<dns value="www.yourserver.com"/> 
</identity> 
</endpoint> 
<endpoint address="mex" 
binding="mexHttpBinding" 
name="MetadataExchange" 
contract="IMetadataExchange"/> 
</service> 
</services> 
<bindings> 
<wsHttpBinding> 
<binding name="BindingTest"> 
<security mode="Message"> 
<message clientCredentialType="UserName" /> 
</security> 
</binding> 
</wsHttpBinding> 
</bindings> 
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" /> 
</system.serviceModel> 
<system.webServer> 
<modules runAllManagedModulesForAllRequests="true"/> 
</system.webServer> 
</configuration>
A noter que dans une application winforms, je récupère bien mon Exception par le biais de mon FaultException.

Quelqu'un pourrait il me dire ce qui pourrait clocher ?

Merci à vous tous d'avance.

(vs2010, frk 4)