I have a silverlight app that I'm trying to run with the Performance Profiler.

When I start the profiler with the setting "ASP.NET web application (IIS)", which appears to be the default choice by ANTS, it runs fine, and I get profile information for what appear to be all the assemblies running on the service (web services, etc.). I don't see any results for client assemblies from what I can tell. I need the results for the client DLLs (Silverlight).

When I select to run it as a Silverlight 4 browser application, the website starts up, but doesn't work correctly (e.g. my saved id/password are not found by the app, and after I type them in, the app appears to hang.) I thought maybe it was just taking a long time, as there was a lot of code to profile, but it never continued.

My first issue, then, is to know the best way to start it to profile the client-side code. I"m also wondering what the difference to ANTS is that I start it ASP.NET or Silverlight, and if there is any way I can ask it to profile both client-side and server-side at once?

dbruey wrote:My first issue, then, is to know the best way to start it to profile the client-side code.

Yes, that's the correct first question I think you are doing everything correct but things don't always behave the same under profiling - so if you're saying that the silverlight app isn't working, I'm suspecting something has broken under profiling and I think the app hanging is the most significant breakage. These things aren't easy to solve so we always try to workaround them instead.

So- can you run your silverlight app as a .Net 4 process (just build it against .Net 4 client?). If so, you can run your system as normal and use the "attach-to-process" feature of ANTS as soon as your system is up and running as normal.

Let's try this first as it makes everything that follows so much simpler.

Good question. I sure don't know a way of making a silverlight app run as a .net app. I think the problems you have are a bit confusing and there is not enough evidence to point at a failure.

For starters, you can't combine results for the web app and the SL app, as they are two completely separate processes. Anyway I don't see why you would need that as the web app typically just serves the XAP to the client, except maybe in the case of RIA I don't ever see them working together.

The advice we usually give first-off is to close all all instances of Iexplore (using Task Manager) before attempting to profile a Silverlight application hosted in the browser because IE likes to load the runtime into a process Profiler doesn't expect it to load into.

But in all likelyhood we will probably have to attach a debugger to the process to find out what Profiler's done to the app to make it misbehave. The logon failure may be inconsequential - it may be crashing the app.

I have found that this works perfectly in ANTS. If it works for you- it would be interesting to see the differences in the projects. If it doesn't work, it will be interesting to see the differences in our environments.

Thanks Chris. I had already decided to start from scratch and see if I could get a simpler Silverlight app to run. I’ll try yours if I can't clear things up with a simple app.

---

I created a new Silverlight application called “AntsProfileTest” in VS2010, and selected the default project settings. I put a button on the design surface and built the project.

I selected “ANTS->Profile Performance” in VS2010. IE opened with the URL http://localhost:8013/, which showed a directory listing of the project (including .csproj, web.config, etc.) I figured it would choose the defaults it thought were most appropriate for the project, but it looks like whatever it was trying to open didn’t work, and IE fell back to showing the directory contents.

I then chose “ANTS->Launch ANTS Performance Profiler”. When I hit the “…” button next to the Silverlight Application URL text box, the resulting file dialog was looking for HTML Pages, so I chose “C:\\projects\\AntsProfileTest\\AntsProfileTest.Web\\AntsProfileTestTestPage.html”

I saw the page with the button come up. So far so good.

I closed the IE window and saw a spinning animation “Summarizing results”. This continued to spin, and I stopped it after 4 minutes because it didn’t seem to be getting anywhere.

I closed VS2010 and started the profiler from the Start menu and got the same results. I wondered if VS2010 was somehow interfering, but the profiler worked the same – “Summarizing” didn’t end.

I started another profile session, this time choosing “ASP.NET web application (web development server)” as the application type.
I selected “C:\\projects\\AntsProfileTest\\AntsProfileTest.Web\\AntsProfileTestTestPage.aspx” as the file, since the “…” button’s file dialog was looking for .aspx pages.

I got a listing of the directory that contained the .aspx file I chose. I’m not sure what to choose for this option.

I know this should be simpler than I’ve been able to accomplish. I’ve looked at the help, which gives some general guidance but I’m not sure what the next steps are.

When you got a successful "rendering" of your silverlight app while profiling - did you notice if you got any results? You should, at the very least, see the red CPU "heart-beat" line come up. Perhaps leave your app running for a good 5 minutes just to be sure- it does take a little time, sometimes. If this works - we're getting somewhere and you should be able to get results from your real app. If that's not working, ANTS is unable to get data form the pipe that links the UI to the process being profiled and that's complicated to debug... It might be worth trying it on any old windows maccine you might have around (even a VM).

I don't see the "heartbeat" line or any output in the profiler window.
I waited over 20 minutes for the spinning animation to complete, but it didn't. I think it's frozen.

More information:

When I start the profiler with the Silverlight options I mentioned above, I initially get a message from IE:

To help protect your security, Internet Explorer has restricted this webpage from running scripts or ActiveX controls that could access your computer. Click here for options…

At the same time that message comes up, I see a box from Microsoft that tells me I need to install the Silverlight client.

I am wondering what the difference is between starting the program in the profiler and starting the program with the debugger in VS2010. It looks like there is an authorization issue or some similar issue.

I was going to mention this in my last post but I was trying one thing at a time. Maybe this clue will lead somewhere?

I chose "Properties" and then the Compatibility tab for the Profiler's exectuable file. I checked "run as administrator" and am seeing the same results.

Are the steps I wrote in my earlier post the correct steps? (June 2, 12:29 pm) Did I pick the right files to profile? I would like to back up to the start and makes sure I'm making the right choices in the "launch" window for the profiler.

I ran the sample you posted.

When started the profiler I chose "Silverlight 4 app" and this is the path I chose:

Other than the differences between our project paths, is that the html file you would have chosen to profile a Silverlight app?

I saw the message "Sent order of 3 Widgets." at the top left corner of the screen.

I waited a few minutes, and nothing else was happening, so I closed IE, then the "Summarizing results..." spinner spun for a while - I closed ANTS down after about five minutes. There was no heartbeat data at the top.

Well, you've done everything correctly - selected the right URLs etc. ANTS is just not doing what it should and I've no idea why (other than it needing explicit administrator permissions). Sorry for all the time you've had to spend on this- the only other things I can think of that helps sometimes its just trying it on a different machine or re-installing the .Net framework. Again, sorry