Home > .Net, Dev > Generate Silverlight 2 Proxy with SVCUtil.exe

Generate Silverlight 2 Proxy with SVCUtil.exe

createUnfortunaly Silverlight 2 didn’t ship with any utility to generate a proxy class from the command line. Generating service proxy classes as service reference isn’t the way to go for me. Michael Giagnocavo wrote a little utility that makes use of a dll shiped with Silverlight to generate a proxy gut this one fails for me when I generate a little more complex proxy then HelloWorld. for example when I use multiple namespaces etc.

The Proxy classes of SVCUtil aren’t compatible with Silverlight 2. But they are not that much different. So I wrote a little utility converts a SVCUtil generated proxy class to a proxy class Silverlight can use. It also makes it possible to seperate your data contracts and your proxy. To automate this I use a little commandline script that executes it all.

silverlightsvcutilrepair
Command script for SilverlightSVCUtilRepair
silverlightsvcutilrepair Source

Generating Silverlight Proxy

  1. Generate Async Proxy with SVCUtil
  2. Run SilverlightSVCUtilRepair.exe
  3. Include the generated file in your project
  4. Compile your code

Generate Silverlight Proxy with shared DataContracts

  1. Generate Datacontracts with SVCUtil
    Give your datacontracts a different CLR Namespace(s)
  2. Run SilverlightSVCUtilRepair.exe
  3. Generate Async Proxy with SVCUtil
    Give the datacontracts a different CLR Namespace(s)
  4. Run SilverlightSVCUtilRepair.exe
  5. Include your generated files in your project
  6. Compile your code
Categories: .Net, Dev Tags: , ,
  1. Guillaume
    March 2nd, 2009 at 09:27 | #1

    Thanks for this cool tools but does it correctly manage the /enableDataBinding flag ?

  2. March 3rd, 2009 at 00:16 | #2

    @Guillaume,

    The /enableDataBinding flag was automaticly added by the tool. But I’ve made an update. Now you have to add the flag to svcutil

  3. March 13th, 2009 at 00:17 | #3

    Thanks for the tool, I really needed this to get things going with services and silverlight.

  4. Roy
    June 3rd, 2009 at 23:33 | #4

    In your Create.CMD application, what is XSDLOCATION supposed to point to? How do I generate the required xsd file?

    Thanks,
    Roy

  5. June 4th, 2009 at 19:28 | #5

    @Roy
    In my project I also had the original xsd’s the service was based off. But if you only have the wsdl or the uri to the wsdl you can use that too. Or you can download the wsdl using the WSDL download tool
    The XSDLocation is [drive]:\[directory of xsdfile]\*.xsd. If you only have one .wsdl file it’s *.wsdl, the wsdl than contains the xsd schema’s.

  1. No trackbacks yet.