views:

513

answers:

2

Hi guys,

Basically, I have a silverlight 2 client (hence my use of SLSvcutil) that needs to access a WCF service.

Anybody know how I can prevent SLSvcutil.exe from decorating OperationContracts with FaultContractAttributes?

I'm running SLSvcUtil against a WCF service who's operations are all decorated by Faultcontracts.

Unfortunately I can't really provide any code, just wondering if anybody has a vague idea. I can't seem to get the excludeType switch working which was my first guess as to how to achieve this.

Thanks

A: 

If you really want to disregard the strong type fault data contract for the operations, you could remove the definition from the services' wsdl. But it would be easier to remove it from the generated classes. (Do a find all fault contract attributes and replace to "")

codemeit
Well, the reason I ask is that by default, the 'Add Service Reference' feature of VS2008 (which I assume uses SLSvcutil) seems to properly remove the FaultContracts. Unfortunately I can't use it as it appears to be horribly broken all of a sudden, forcing me to generate my proxy classes by hand using the command line. I don't want to manually remove the FaultContracts by hand because I'dhave to do it after every service update, which happens very, very frequently in dev.
Hovito
have you tried svcutil.exe rather than SLSvcutil.exe? as far as I know svcutil is used when adding service reference.
codemeit
No, sorry..I forgot to mention this is a silverlight project accessing a WCF service. I'll update the original query. Sorry.
Hovito
A: 

EDIT - I got it to work with SL 3 runtime... I had to remove all the old references to System.ServiceModel and System.Net and add them back from this location (I run x64 windows)

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v3.0

Once I did that - it worked! Sorry if you're still targetting the 2.0 runtime but I thought I'd post this update in case anyone finds this page in the future...

This might have just been "my issue" since I use x64 windows... Here is what the new proj file looks like for the assembly references:

<Reference Include="System.Net, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v3.0\System.Net.dll</HintPath>
</Reference>    <Reference Include="System.ServiceModel, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v3.0\System.ServiceModel.dll</HintPath>
</Reference>

=============== OLD answer below ===============

I've been trying to do the exact same thing with no luck so I'm gonna say "this can't be done at the moment" and that's REALLY annoying...

If you look at the reference.cs and the emitted .cs the top of the class shows you that using "Add Service Reference" you get:

// This code was auto-generated by Microsoft.Silverlight.ServiceReference, version 2.0.5.0

Using SlSvcUtil (a v3.0 tool btw) you get:.

// This code was auto-generated by slsvcutil, version 3.0.40624.0

So I don't think you'll be able to "back port" to v2.0. Unfortunately - you also CAN NOT use SlSvcUtil with the 3.0 runtime! (which I find ludicrous - or I just can't get it to work properly)

I am targetting the 3.0 runtime and used SlSvcUtil and "out of the box" it tells me

The type or namespace name 'FaultContractAttributeAttribute' does not exist 
in the namespace 'System.ServiceModel' (are you missing an assembly reference?)

The class DOES exist in System.ServiceModel 3.0.* but Silverlight is using 2.0.* where it does not exist... The kicker - try adding a reference to the 3.0 version and you get greeted with:

You can't add a reference to System.ServiceModel.dll as it was not built against the 
Silverlight runtime. Silverlight projects will only work with Silverlight assemblies

So even if you were on v3.0 - you'd be SOL - just like me...

Hopefully someone can reply telling us HOW to do it but I don't think it's possible... SOMEONE - PROVE ME WRONG PLEASE!!! :)

Sorry man...

dovholuk