How to debug Silverlight against Google Chrome - silverlight

Does anyone know how to debug a Silverlight 2 app running in Google Chrome from Visual Studio? Even after making sure that Chrome is the debugging browser, breakpoints are still not being hit.

Have you tried attaching to Chrome manually? Tools > Attach to process?
Chrome isn't officially supported but there are hacks.
Here for example. Halo's comment may give you some help too.

You can have more than one browser running on your localhost.
1) Hit F5 to run debug. Probably opens IE or whatever your default is. F5 your way through the breakpoints until it's loaded. Leave this IE open.
2) Open your other browser, coping the localhost Url into the new browser and run it. New browser should hit the breakpoints.
This works with all browsers, and even emulators like BlackBerry emulators.

Attach to the process manually (Tools > Attach to process), but make sure to attach to the chrome process that lists its type as "Silverlight, ...". Its title should be blank.
If you see your application name in the title, it's because chrome has a separate process for the HTML form that your Silverlight app is in, and the html's title probably matches. Attaching to this process does not load the Silverlight assemblies.
I usually will start debugging the app in IE to make sure that the most recent changes are compiled and running, then launch chrome, clear its cache ('cause it likes to hang onto Silverlight data), paste in the url from IE, and then stop IE and attach to chrome. Extra steps, but worth not spending 3 hours to figure out you are looking at cached assemblies.

This is an issue with Visual Studio interacting with Chrome: http://code.google.com/p/chromium/issues/detail?id=45560. My guess is you need to wait for a Visual Studio patch, but I honestly wouldn't hold your breath. The majority of Silverlight developers just use IE or FF for debugging. (Apparently even FF has some issues now that they've sandboxed their plugins: http://timheuer.com/blog/archive/2010/08/16/enable-silverlight-debugging-in-firefox-visual-studio.aspx#20476). As much as I hate IE, it's really your best bet for debugging Silverlight apps.

Simply set SL app as startup prtoject instead of asp.net and press F5

Related

Run WPF application in browser

I have my application wrote in WPF. Now, i want it to run in browser so I've read about it and I know that XBAP is my solution.
What is my problem? It won't run on my PC. I checked every popular browser (chrome, FF, IE, opera) and nothing. Browsers can't handle .xbap files and just downloads it.
I try and try and nothing but above happened. Can anyone guess why it don't work? Is it deprecated technology, i have too-new browsers or what? Every entries I found about it are 2-4 years old.
Firstly for Internet Explorer (IE9 onwards) you need to ensure that you have enabled XBAP/XAML support:
For Firefox and Chrome you have to do something a bit different:
How can I get my XBAP to run in my browser instead of downloading it on Windows 7?
But in addition to the above you need to be aware that when you run an XBAP application it runs in the Internet Zone....so your biggest problem is that normally you don't have full-trust...therefore your application can't call privileged code...if it tries to then you get security exceptions.
http://www.tarkia.com/blog/tag/difference-between-wpf-application-and-xbap-application/
http://www.tarkia.com/blog/2009/11/26/understanding-xbap-full-trust-partial-trust-certificates-and-more%E2%80%A6/
One way to get your XBAP to be "trusted" is to get it signed with a certificate (you should purchase a proper one from Verisign rather than use a test certificate) and deployed with ClickOnce.
http://blogs.microsoft.co.il/blogs/maxim/archive/2008/03/05/wpf-xbap-as-full-trust-application.aspx
http://blogs.microsoft.co.il/blogs/maxim/archive/2008/03/31/how-to-run-wpf-xbap-application-in-full-trust-mode-post-2-certificate-extraction.aspx
http://scorbs.com/2007/01/10/xbap-trust-levels/
Or you can keep your application as a regular WPF .EXE and use ClickOnce to deploy it from a website but run it locally with full trust.
not straight forward way, you can find you answer Microsoft MSDN Forum

Any advice on debugging / engineering Silverlight apps that need to run in Firefox?

I'm a developer who does a lot of Silverlight work and I experience some frustrations from time to time with various browsers not playing nicely with Silverlight. Particularly, I've noticed that Firefox will frequently interact poorly with Silverlight and attack the plug-in for attempting to interact with the browser.
Specifically, I've seen various versions of Firefox crash when:
The user initiates an action that requires clipboard access and a standard Silverlight security dialog is supposed to display. Other browsers handle this just fine.
A Silverlight application asks the browser to display a messagebox to the user (I've since used custom Silverlight UI for this because Firefox just wasn't liking this)
Silverlight is being run in Firefox with GoToMeeting running
The plug-in takes a bit of time on an operation (much less of a tolerance than other browsers, but this is usually something I can do something about)
Quite a few other times for little reason in particular
What can I do as a developer to avoid these sorts of issues for users that run Firefox? What can I do to analyze the problem when the SL plugin crashes? I don't feel that telling people to use Chrome or IE is a viable solution, but there aren't a lot of resources available on catering SL apps to run well with Firefox.
The best thing you can you assuming you are fulfilling the requirements is to report these bugs. Although some of them sound more like Firefox bugs, like "Silverlight is being run in Firefox with GoToMeeting running".
Another workaround instead of asking your users to use another browser could be to encourage them to install the application as oob.
This is a known bug in Firefox, if you have dom.ipc.plugins.enabled set to false in Firefox. See bug 602502 in Bugzilla.
If you can, set it to true, and you should be just fine.

Debugging silverlight application problem

My VS2010 doesn't stop at breakpoints inside of silverlight application. It appears that no symbols for it have been loaded during debugging. When I hover over the break point it says "The braekpoint will not currently be hit, no symbols have been loaded".
I have tried all of possible solutions offered by google and have no success. The problem occurs even when I create brand new silverlight app hosted by an ASP .NET web project. All of my project configuration looks fine - silverlight debugging is enabled in the Web project.
I am using silverlight 4.
here a link to the sample project created out from the tepmlate.
Any thoughts ?
P.S I just tried to reinstall VS2010 and the problem still exists.
EDIT: I just tested the same project on another machine and it stops at the break point it seams that the problem is somewhere in the configuration of VS or silverlight.
with Matt Dotson's help I managed to attach the debugger manually. However this solution is not good enough for daily use.
Depending on my experience in Silverlight following these steps keep your project debug-gable.
Condition 1>
Firstly we need to be ensure that in Web Project's properties there is a Web section, as you see below Silverlight checkbox must be checked.
Condition 2>
Follow In Menu Debug => Attach Debugger>
Visual Studio sometimes can't attach debugging platform you need to lead the way :) . By this way you may debug other platforms,(also you may debug your product platform but pdb files must be sync and don't forget you may suspend your product platform using this).
Condition 3> Your default web browser may be Firefox,Chrome or other than IE.By Visual Studio default try to attach to IE. But when you run VS calls default browser,so you need to have a manual attachment in Condition 2 or set your default browser by right clicking on default page > Browse with .
Condition 4> There is xap file generally located in web project\ClientBin directory. Sometimes after build operations this file can't be replaced and your ProjectDll and your Project PDB files not be sync. This cause wrong line match while debugging or can't find a debugging file attached caution. I strongly suggest delete all generated files in Bus project and delete Clientbin\ProjectName.xap file. After rebuild all it must be ok!
Hope helps.
What broswer are you using? You need to be using Internet Explorer to debug silverlight projects.
I have had a similar frustrating experience with this but in my case the solution was very simple. It seems that somehow, and I really have no idea how, the debugger option for Silverlight had become unchecked in the properties on the hosting ASP.NET project.
I just assumed that as I had been previously debugging, this option was set and I didn't bother to make sure that this was this case. Just goes to show that one should always check the basics first; if I had done that it would have saved me some time.
To check this in VS2010, right-click on the project and select properties, change to the Web tab and check the Silverlight option at the bottom of the page, in the debuggers section.
Also see the debugger to a silverlight process
http://msdn.microsoft.com/en-us/library/cc838267(VS.95).aspx
If that doesn't work, then
reset iis (if you are debugging in that)
delete temporary asp.net files (%SystemRoot%\Microsoft.NET\Framework\versionNumber\Temporary ASP.NET Files)
clean and rebuild your solution
The resolution came after 2 days of headbanging. It appears that the link which Malcolm gave covers exactly my problem but my I was narrow-minded enough not to pay it enough attention because when I run the debugger as long with the app my default browser was FF. So I thought that after the FF starts I can load the page from IE or Chrome.
Actually the problem is that the debugger cannot be attached to the silverlight project because of the FF. And when I load the app from IE or Chrome the debugger dis still not attached.
Thanks to everyone that tried to help.
if you have multiple project, Rebuild the project separately that you want break point. Its work for me
Try also picking internet explorer from browser list menu as your browser

Debugging Silverlight Applications

As hard as I try, I cannot get my silverlight app to stop on break points. I've tried both in and out of browser debugging.
Steps I've done:
Repeatedly cleared my internet
cache.
Made sure Silverlight
debugging is enabled in my test web
application.
Made sure symbols are
loaded by placing a reference to the
silverlight app in my test web
application. (I had the hollow red
dot problem, but this fixed it)
Restarted visual studio and the ASP.NET Development Server
Made sure I was attached to the right process by manually attaching to either sllauncher or the browser hosting the silverlight app.
Ensured that the xap file is being updated in the ClientBin directory after rebuilds.
Cleaned and Rebuilt the solution multiple times.
From my searches, I've found that debugging issues are usually caused by one of the above, but nothing seems to work. It looks like I'm debugging, but the application never breaks. Anyone have any experience with this?
Check the properties of the Web Application / Site. In Visual Studio, Right Click --> Properties. Click the 'Web' tab on the lower left. On the bottom under the 'Debuggers' section, ensure that Silverlight is Checked.
Are you use IE for application or other browser? Be sure that you use an IE.

Turn Off Silverlight Plug-in Warning in Chrome

I'm working with a Silverlight 3 app and using Chrome as my test browser. While debugging I keep getting the popup message:
Plug-in Unresponsive
The following plug-in is unresponsive:
Unknown Would you like to stop i?
Yes/No
How can I turn this off in Chrome? Can VS be set to shut it off only when debugging? It's a real pain when debugging.
Thanks,
Add --disable-hang-monitor to chrome shortcut
Nick - are you using Chrome early builds on the Mac? There are some known issues with Chrome/Silverlight that we are working through with the teams -- most scenarios work though. Is this something you can share so others may verify?
To be honest, I set IE9 as my default browser when debugging Silverlight and switch back to Chrome afterwards. Chrome doesn't seem to communicate to Visual Studio (or vice versa) so I can't get breakpoint and exception information when using Chrome.

Resources