Silverlight application under IE attached to Windbg - silverlight

Is it possible to attach Windbg to a Silverlight based application running under internet explorer ( or any other browser)? If its possible, then will I have to attach windbg to the browser and this will get me into that mini CLR under Internet explorer?

I am not an expert on Silverlight, but you can use WinDbg with Silverlight apps in the browser with some limitations. Also, since you stop the plug-in some browsers such as Chrome will constantly complain about the plug-in not responding.
The first thing you need to do is to make sure you load the correct version of SOS. Silverlight comes with its own version and that's the one you must use. To load the correct version use the CLR module to identify the associated version of SOS. The command is
.loadby sos coreclr
Notice the CLR module is called coreclr in Silverlight.
Use the .chain command to verify that you have the correct version of SOS loaded. If you already have a version of SOS loaded make sure to clear your WinDbg workspace first.
Following that you have access to the regular SOS commands. I've had limited success using some commands such as !clrstack and !dso, but others such as !threads and !dumpheap work as expected.
If you just attach, the !clrstack and !dso commands do not work as expected. However, if you set a breakpoint using !bpmd they will work in the context of the breakpoint. This is probably due to how code is run in a Silverlight app, but as I said I am no expert on Silverlight.
This applies to Silverlight 4.
Tess has a post about debugging Silverlight 2 apps in the browser.
This long post is also worth taking a look at.

Related

All converted apps including samples fail to run with a 'The parameter is incorrect'

I'm trying to convert a WPF oneclick installed application and so everything should be pretty straight forward. However, whenever I run the debug project, I get
'The parameter is incorrect'
in a message box popup and I can never run the app.
This happens for my app while trying to debug, all the samples from github, and even the DAC application from the Windows Store. The error pops up even once the app is installed and showing in my application list.
I'm on the latest build of the Creators Update.
There are various errors in the event viewers, but they seem to be a common occurence for WinRT apps.
Any ideas at all?
If you have the WPF project in VS2017, I'd recommend to package directly from VS without using the DAC. see the article for more information https://learn.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-packaging-dot-net
The problem appears to be related to the May Security Update. I restored Windows to the factory defaults and everything works fine.
However, once I install the the May Security Update to address this bug with Sql Server and Filestreams, the Desktop Bridge Debugging project stops working.
I'm going to throw out a random guess that it's related to the Microsoft Malicious Software Removal Tool, as the event viewer logs mentioned an issue with the 'parameter is incorrect' referring to the Microsoft.MRT.
Of course it could be anything, and as only 7500 people have even downloaded the Desktop Bridge Debugging project in the first place, I doubt it's high on the list of Microsoft Developer Priorities.
And to be completely honest, it's really probably my fault for not rewriting the app as a UWP app, after rewriting it as a Windows Forms app, and as a Silverlight app, and as a WPF app and on and on and on. Although, I'm not sure how many glasses of Kool Aid are left in the punch bowl for me.

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

How do I deploy a 3D Silverlight 5 web application to a third-party hosting server?

What I want to do
I've been playing around with the newly released Silverlight 5 and Silverlight 5 Toolkit (December 2011), and I would like to try deploying my 3D Silverlight test application to a third-party hosting server (AppHarbor in my case, but I'm open to other options).
My test application is simply the default Silverlight 3D application that you get when you create a new Silverlight 3D app:
Blog: http://blogs.msdn.com/b/eternalcoding/archive/2011/12/10/silverlight-toolkit-september-2011-for-silverlight-5-what-s-new.aspx
It looks like AppHarbor (and most other hosting sites) require that you copy the required Silverlight 5 DLLs into your project, because they don't have the required SDKs/Toolkits installed on their servers.
Seems fine in theory, but I have no idea how to actually do this with Silverlight.
The problem
The problem is two-fold:
I'm not sure exactly which DLLs need to be manually copied into my project, and I'm not sure how they should be included and referenced.
After some experimentation with copying a few of the Silverlight XNA DLLs into my project and referencing the local project DLLs (instead of the SDK-installed and Toolkit-installed DLLs), the basic 3D Silverlight app now crashes when I run it in the browser -- locally. (The Silverlight plugin crashes.) I didn't have this problem before I started fiddling with the references and DLLs; the default project works just fine. So I haven't even gotten to deploying to a hosting server, because it no longer runs locally.
An aside
On the latter point above (Silverlight plugin crashing), the issue seems to be related to the 3D Silverlight functionality, which apparently requires elevated trust/permissions -- admittedly, I don't fully understand how that all works yet.
Generally speaking -- irrespective of all of this DLL/reference fiddling -- it seems like I need to check "Require elevated trust when running in-browser" in the Silverlight3dApp project properties to get the spinning 3D cube app to show up in the browser. Alternatively, if I leave that unchecked, I need to manually right-click the Silverlight 5 app in the browser and enable 3D graphics on the Permissions tab. (Side note: I'm interested in how this will effect my end-users if I ever do get this deployed. Will they have to manually adjust permissions in the same way? Anyway, that's a question for a different day.)
The point of this aside:
The Silverlight plugin does not crash if I leave everything the way it is by default.
If I copy the Silverlight DLLs into my project and reference them locally, the Silverlight plugin crashes if 3D permissions are enabled.
If I copy the Silverlight DLLs into my project and reference them locally, the Silverlight plugin does not crash if 3D permissions are disabled.
The question
Has anyone successfully deployed that basic Silverlight 5 3D app to a server without Silverlight 5 (and the Silverlight 5 Toolkit) installed?
How did you do it? What files need to be copied into my project and referenced locally? Which references (if any) need to be removed?
Sub-question: If anyone has any insights about the elevated trust/permissions issue, I would love to hear those as well.
For AppHarbor I create a folder in the Silverlight project (lib) and copy all assemblies that I am dependent on and mark all the assemblies with copy to output.
Next I use subst to make a virtual drive that points to this folder and I add all the references to the assemblies on that virtual drive. (This is not needed for AppHarbor but this way I can check out my code to any folder on any machine I want without messing up the paths)
Note that you also need to add these dll's to the repository (git/mercurial) because a standard .hgignore file will skip the *.dll files.
Have you verified you are running the latest runtime for Silverlight? Did you have a previous developer runtime installed? http://www.microsoft.com/getsilverlight/get-started/install/
Hmm... I'm going to go with the above answer. I'm using the latest Silverlight 5 runtime and Silverlight 5 Toolkit and have not had any issues. Here's an app where I'm loading and animating an FBX model in Silverlight (it does require you to right click and set the permissions) and it works fine:
http://www.dustinhorne.com/necodecamp.html
As an aside I'm wrestling with whether to run in elevated trust or force the user to allow 3D acceleration. Personally I hate making the whole app elevated trust just for the 3D stuff from a security standpoint, although if you want to run it out of browser you may want to do that anyway and sign the app with a code signing certificate.

Why does Inspect.exe not display the AutomationId and other UIAutomation properties when running in debug?

I've been using Inspect.exe from the Windows SDK to examine the properties of a WinForms application but noticed that I didn't see any of the properties (for example, the AutomationId) whilst running the application from Visual Studio (F5 to run.) However, if I ran the .exe from the bin\debug folder I could see the properties fine.
The source I was using was example code downloaded from UI Automation Custom Provider Samples - Part 3.
I'm wondering why this happened since I'm sure another machine that I had tried this on worked fine and I wasted time poking around in debug mode wondering why my UI Automation properties weren't visible. Obviously there's a workaround but I'd like to understand why this was happening and have a record of the problem for other people to find!
I've struck upon the answer - because I had launched Visual Studio as Administrator but the Inspect.exe tool as standard user then the properties being reported back were a sub-set of what I should have seen. As soon as I launched Inspect.exe as Administrator it worked!

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

Resources