Debugging embedded flash (swf) - winforms

I have a windows form application that "plays" an Flash SWF file. I am seeing random Method: FlashMethodInvocation Exception: System.AccessViolationException errors. The output only gives me the stack trace of the windows form application, not the actionscript, where I believe the real error is occurring.
I have the source code the swf as well, its all written in ActionScript 3 and I use flashbuilder to create it.
The windows form application is written in C#. The windows form application creates an instance of the ShockWave ActiveX control which is then told to load the swf. There is interaction between the SWF and C# code through the external interface provided in actionscript.
The SWF actionscript plays fine for hours before the crash. Unfortunately, the actionscript stack trace is not included in the error when it bubbles up to the windows form application.
I would like to see what is happening in the actionscript at the time of the exception. Any ideas how I can find the actionscript stack trace?
Matt

I was once in a situation similar to yours, and I remember having resolved it by replacing the "regular" Flash Player with its "debuger" version. You say you are using the ActiveX version of the player, so
1) first download this file:
Flash Player content debugger for Internet Explorer - ActiveX
2) Install it, then navigate to: "c:\Windows\SysWOW64\Macromed\Flash\", there you should find a file named something like "FlashUtil*_ActiveX.dll", which was just freshly replaced (check the file's date). This is the debugger version of the Flash player you just installed.
3) Overwrite this file in your windows form application (I assume you included the Flash Player in the application, rather than relying on the player being available on the host system, which I wouldn't recommend).
4) Then, in your ActionScript project (in Flash Builder) create a debugger version of your SWF (just launch the project in "Debug Mode", and copy the resulting SWF file in your windows form application.
5) Keeping the debugger running in FlashBuilder, interract with your windows form application until it produces the RTE. You should see the trace of the ActionScript error in Flash Builder. Of course, you can set breakpoints in Flash Builder and debug as usual.
You may want to use a form of automation that repeats the whole process (I'm thinking of ANT or the Flash Builder's Externals Tools (is that the right name?) — you could even have your windows application automatically launched by FB, after it first creates a new SWF file and places it in the right folder).
Hope this was clear enough.
Good luck!

Related

Debugging a Native .dll in a Silverlight 5 application

I am writing a Silverlight application that takes advantage of the P/Invoke functionality added to Silverlight 5. I've written a native .dll that takes a bitmap from the managed code and uses a 3rd party library (OpenCV) to process it.
My .dll gets loaded correctly and works fine, but I am not able to hit any breakpoints I set anywhere in the Native code. Visual Studio says that the breakpoint will not be hit as there are no symbols loaded for the document. I tried copying the corresponding .pdb files to the path where the .dll is loaded from, but it didn't help. Additionally, the .dll doesn't show up in the Modules window when debugging, so I can't manually load the symbols that way.
Is there any other way to get the debugger to load the needed symbols?
When you start a SL5 app, VS starts a .NET debugger. This debugger is unable to debug native processes.
You could start another instance of Visual Studio, and use the "Attach to process" dialog under the debug menu, and attach the native debugger to the targeted process. Note that I am not sure that you can attach a Native and a .NET debugger at the same time on the same process.

Silverlight application under IE attached to Windbg

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.

Capturing trace/debug information from a Silverlight OOB app running on a Mac

I'm having a problem with a trusted Silverlight 4 OOB app when it runs on a Mac.
In order to debug I'd really like to be able to capture the debug/trace information output by the app. (The problem is in in code running in a background thread so outputting debug information to the screen isn't practical and risks creating new issues.)
Ideally I'm looking for the Mac equivalent of DebugView, if there is one.
If not, any tips on other approaches to debugging htis will be greatly appreciated.
In the past I have created a com visible dll in c# that simply uses the standard win32 outputdebugstring call to output debug info. This can then be called from within Silverlight using COM automation :-)

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

Hosting Flash movie in a WPF project

I want to host a SWF (Flash animation) in a WPF project.
I searched Google and found something. I tried that technique but had some troubles.
In this article, it says:
**Then, as mentioned in this posting, it is necessary to run AxImp.exe from
the .net sdk on the Flash ocx to
generate following files.
1. AxShockwaveFlashObjects.dll
AxShockwaveFlashObjects.pdb
ShockwaveFlashObjects.dll
AxShockwaveFlashObjects.cs In Visual
Studio, add the references to the
AxShockwaveFlashObjects.dll and
ShockwaveFlashObjects.dll generated
by aximp**
But I couldn't understand this. Can anyone write it out step by step? I am new to WPF.
you could look at the WebBrowser class. then have your flash on a html page that the browser control is pointed at.
Busra, take a look at AxShockwaveFlashObjects and ShockwaveFlashObjects from Flash ocx
I think that has what you are looking for.
Essentially, you need to open a dos prompt, and run
C:\Windows\SysWOW64\Macromed\Flash>"c:\Program Files (x86)\Microsoft SDKs\Window
s\v7.0A\Bin\aximp.exe" Flash10n.ocx /nologo
Generated Assembly: C:\Windows\SysWOW64\Macromed\Flash\ShockwaveFlashObjects.dll
Generated Assembly: C:\Windows\SysWOW64\Macromed\Flash\AxShockwaveFlashObjects.d
ll
Keeping in mind, you're paths may very by if your machine is 32bit, and on where the visual studio sdk is installed on your machine.
#Blounty, I don't think that was his intent. He wants to run the actual flash file inside his WPF application.

Resources