Skip to main content

Microsoft Silverlight

Answered Question SL 2.0 Service model won't recognize FaultContractAttributeRSS Feed

(0)

replytochandru
replytoc...

Member

Member

6 points

9 Posts

SL 2.0 Service model won't recognize FaultContractAttribute

I have Silverlight 2.0 client consuming WCF service. The WCF Service is integrated with Validation Application Block of Enterprise library 3.1 (May 2007). The SL client has corresponding code to handle Fault exception returned by WCF. 
After adding the service reference to SL application and when i build the solution, i am getting compilation error:

The type or namespace name 'FaultContractAttribute' does not exist in the namespace 'System.ServiceModel' (are you missing an assembly reference?) C:\WCFValidationBlock\ClientSilverLight\Service References\ServiceAgent\Reference.cs 

After some investigation i found that the WCF service application has reference to System.ServiceModel.dll, which is of version 3.0.0.0 and SL application has its own set of assemblies and it works only with them. The System.ServiceModel.dll that SL application refers to is of version 2.0.5.0

When i try to manually change the assembly reference of SL application to 3.0.0.0 it throws an error message which says "You can't add a reference to System.ServiceModel.dll as it was not built against Silverlight runtime. Silverlight projects will only work with Silverlight assemblies".

Can anybody help me in resolving this and make the SL client application work along with WCF service (with Validation Application Block).

Any alternate solutions are welcome.

Thanks
Chandrashekar 

Psychlist1972
Psychlis...

Contributor

Contributor

6045 points

973 Posts

MicrosoftModerator
Answered Question

Re: SL 2.0 Service model won't recognize FaultContractAttribute

I don't believe you'll be able to do that in the currently implementation. The client-side WCF stack in SL2 Beta 1 is a subset of what WCF has to offer. You also cannot reference platform dlls in Silverlight.

Here's a post of mine that may help you with basic WCF integration.

Pete

Silverlight.net Moderator
MVP: Silverlight, Silverlight Insider
Author: Silverlight in Action, 2nd Edition
POKE 53280,0 - My Blog

Opinions are my own. Oh, and I don't work for Microsoft.

replytochandru
replytoc...

Member

Member

6 points

9 Posts

Re: SL 2.0 Service model won't recognize FaultContractAttribute

Thanks Pete.

InquisitorJax
Inquisit...

Member

Member

80 points

60 Posts

Re: SL 2.0 Service model won't recognize FaultContractAttribute

Does that mean that if your WCF services have FaultContractAttribute specified, you cannot consume them in Silverlight?

All my service contracts are decorated with a faultContract tag:

[FaultContract(typeof(MyCustomFault))] 

 ...does this mean I STILL don't have any way of consuming these services in Silverlight BETA 1?

Are there any work-arounds for this (that don't involve editing the services)?
 

EDIT: I managed to make successful calls by doing the following:

Press the "Show all files" button.
Navigate to the References.cs file in the service reference.
Manually delete the FaultContract tags on the contract definition tags.

Obviously you can't handle the soap faults if the get thrown, but at least the the calls can be made.
 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities