WCF Startup performance in Silverlight 4
I'm running a Silverlight 4 application that has a WCF service reference to a service that has a lot of contracts involved.
I noticed that my startup performanc开发者_开发知识库e was horrible so I profiled it and found that 7 seconds of time was spent generating serialization code on the first WCF call.
I know there is a way to improve startup time by using the XmlSerializer (explained here). This is done by generating the serialization code into a separate assembly ahead of time but I can't seem to figure out how to do this in Silverlight.
Has anyone done this before? Is it even possible? Any other ideas that might help are also welcome.
Thanks.
The article you linked to describes how to use svcutil.exe to pre-generate the classes, but if you're using either the "Add Service Reference" dialog box in Visual Studio or WCF RIA Services, this code generation is already done for you. So that's not where I would look for any performance boosts. And 7 seconds seems way too long for that anyway, unless you've got literally thousands of different classes that you're trying to spin up. My strong suspicion is that you've got a different problem entirely. Any operation taking seven seconds is either algorithmically or IO bound. And my bet is that this is I/O: either network I/O in reaching the WCF service, or possibly I/O from the WCF service to its own data sources. Load up a sniffer of some sort (Wireshark, Firebug, something along those lines), and get a better look at what's happening on the network. That's where I'd start, at any rate.
It turns out that if you use the Advanced Developer Extensions you won't have the same startup performance problems as you do when you add a WCF reference.
精彩评论