Debugging a Native .dll in a Silverlight 5 application - silverlight

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.

Related

Debugging embedded flash (swf)

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!

MSVCR120.DLL Required

I was asked to download the specified DLL after running one of my apps on a secondary computer. The only problem is whether or not it should have been required. I obviously code in Visual Studio, but it is in pure "C" and a Win32 project, so I'm just wondering if this is normal.
if you don't want to load CRTs, change run time library to static library. (MT)
or you need these dlls in installed visual studio\VC\redist
//after your comments//
MSxx##D.dll D means Debug.
if you link any library built with debug run-time, the exe needs debug runtime library

Unable to load assembly. Ensure that the file is a valid .Net Framework assembly

I have an issue in Microsoft Visual Studio 2008 developing a Smart Device Solution with .NET CF 3.5.
The main project is Smart Device Application Project (normal executable for smart devices - WinCE).
This project is referenced to Microsoft.WindowsCE.Forms assembly as follows.
Now, if I try to add a new item to the application project and choose the item to be an inherited form , VS pops up an error that the assembly is not a valid .NET project.
But dialog with all forms in main project is still shown.
This EXE is also SDAP executable (WinCE device). But this EXE has never been referenced to and more - it is exluded from Build all process.
This warning/error message has been never shown before.
What options should I check to solve this problem?

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.

Debugging Visual Studio 2010 DLL Project

I'm trying to debug a C/C++ native DLL project from Visual Studio 2010. I'm attempting to follow these instructions:
http://msdn.microsoft.com/en-us/library/c91k1xcf(v=VS.100).aspx
I want to use the built-in debugger and be able to step code, examine structures, etc. as I would do with a regular .exe project. The instructions on the page above describe a Debugging category under Configuration Properties which I do not see.
http://img707.imageshack.us/img707/4402/lalasz.png
Just pressing F5 to debug results in the following error:
Unable to start program 'C:\Users.......Test.dll'
I've used the debugger for regular .exe projects many times and it works fine on this computer. I'm not sure if I'm just missing something very obvious right now though.
Edit: Since I didn't make it clear from the start, I want Visual Studio to LoadLibrary my DLL into a stub process and let me debug at a source level from there, much like how OllyDbg does it.
My DLL is not the type that holds a bunch of functions to be exported and called. Instead it does a switch/case in the DllMain and on DLL_PROCESS_ATTACH will spawn a new thread. Therefore all I need Visual Studio to do is to load my DLL into a stub executable and allow me to set breakpoints, etc.
You probably have as the startup project the one that produces the dll.
You have two choices: either change the startup project to another project that produces an executable that uses that DLL, or configure from project properties the debug settings for the dll project to start an external application that uses that dll (Project Properties/Debug/Command).
Native DLLs cannot be run standalone - they must run in the context of some program. See this part of the instructions page you referenced.
"If you start debugging from the project that creates the DLL, you must specify the executable you want to use in debugging the DLL."
You right-clicked the solution name in the Solution Explorer window and got the solution properties. Note that the window says "Solution Test Property Pages".
Right-click the project name (Test in bold) instead to set the project options.
You would run into this problem from a Managed project also. What Visual Studio is telling you is that it cannot run the DLL, just the same as you cannot double-click a DLL from Explorer, and have a program run.
In order to debug the DLL, write a small console application which calls functions from your DLL and exercises your code. If your DLL has a function foo(), call foo() from main in your console application. Set the console application as the "Startup" project, by right clicking the project name in the Solution Explorer and selecting its option.
Then, when you press F5, you will run the console application, which will call the DLL.

Resources