Unable to debug native code from managed despite enabling native code debugging - visual-studio-debugging

I have a managed project (.net 4.6.2) which calls into a native dll. If I put a breakpoint in the native code, it hits it, but if I try to inspect stack variables I get a rather annoying
Inspection of unmanaged type 'MyTypeInHere*' requires unmanaged
debugging to be enabled. Please set the debugger type to 'Mixed' and
try again
I followed steps from https://learn.microsoft.com/en-us/visualstudio/debugger/how-to-debug-managed-and-native-code?view=vs-2019, Debugging unmanaged code while debugging managed code but I still cannot inspect types.
In the managed project properties, under debug I've enabled enable native code debugging and under the build page I've checked allow unsafe code. Further in launchSettings.json, I have "nativeDebugging": true
Also note that in the native project property settings I've set the Debugger type to mixed.
Does anybody know what's preventing me debugging native code?
Thanks

Does anybody know what's preventing me debugging native code?
It is quite strange and I followed the sample which your link provided and it works well. In fact, all the steps are just the rule.
So please check these:
1) Please make sure that your c++ project is using Active(Debug) Configuration and x64 platform. When you change Debugger type to mixed and then click Apply, please remember to rebuild the project.
2) when you reference the native code into C# project, please close the VS Instance, delete obj,bin,.vs hidden folder and then reopen your c# project. After that, please make sure that you check Enable Native Code debugging, then rebuild the entire solution.
3) Add breakpoints where you want to break and begin stepping through the code. Make sure your have placed your breakpoints in code which the C# application calls into.
4) change the target gramework to 4.7.2 to test again.
5) Please try to create a new net framework 4.7.2 c# project to test whether the issue is caused by the old project.
In addition, if all the steps does not work, please do a repair in VS Installer.

Related

How to setup the launch.json for debugging react backend project inside VS code?

I am learning React.js and would like to enable debugging in VS Code. I tried many different scripts but they never stop at the breakpoints. I want to stop at breakpoints in the VS Code, not in the browser. Could someone show the correct script for it? Simply, I want to run debugging as in ASP.net in visual studio IDE.
break point example :

Unhandled exception in WWAHost in Cordova APP using Angular

I'm currently developing a windows modern app using Foundation for Apps and cordova. The app crashes in many ways during navigation, sometimes even immediately after running it.
The crash is this one
And i can't manage to debug it in any way.
I've tried setting up a window.onerror and a WinJS.Application.onerror catch all function with no results. Apparently the crash happens at a lower level. I've also inspected the event viewer but no info are available.
What happens is apparently similar to this question: How to debug unhandled win32 exception in WinJS Win8 store app which is unfortunately unsolved.
What are my options here?
I had the same issue with Visual Studio 2015, Windows 10 and cordova 5.1.1 when I transfer the project to another dev environment. It only occurs at the Windows-x64 app build configuration for the local machine.
After successful building, the app window launches shortly and after that, the win32 exception like the screenshot from sPoz came up. It was reproducible every time.
I try to repair Visual Studio and also I checked the environment variable from my solution as it is described in this Microsoft Article. But I had no luck.
Nothing helped, but simply open the config.xml file and change the Windows Target Version from "Windows 10" to "Windows 8.1" solved the problem and I could run the app with no error:
After that I can turn back to "Windows 10" and everything is fine. This was reproducable on two dev machines.
I do not exactly know if the moved project was the source of the problem and maybe the rewritten config.xml triggers any rebuild mechanism.
Most likely you are hitting an issue related to DOM Ex WWAHost.exe error on Windows 8.1 (apparently fixed on Win10). There is a workaround that should work for most apps; before you click around and get the WWAHost.exe exception, close the DOM Explorer window. This should enable you to debug by hitting breakpoints, etc. If you need to use DOM Ex against a Windows target, you might need try debugging against a remote device (see Kenneth's suggestion here: Why is Cordova Windows 8 app causing an unhandled win32 exception occurred in wwahost.exe?)
What are you using to develop the app ? The Visual Studio Tools for Apache Cordova ? Or Cordova with CLI ?
If you are using the plugin, you must launch the generated WP project to debug. The debug of WP app is not supported currently with the plugin.
I was getting same error during development of cordova windows tablet application, using Visual Studio Enterprise 2015. So far, I was doing try to close DOM-Explorer and use breakpoints and javascript console. After that, while searching javascript intellisense issues with Visual Studio, I figured out that my problem was fixed. What I did to get rid of this problem is that:
Open Tools > Options
Select Text Editor > Javascript > Intellisense > References
Add following references ( angular.intellisense.js, domWeb.js, domWindows_8.1.js ).
I don't know what are the correct reference files, but with these 3 reference files added, my problem has been solved.

How can I determine an application's software prerequisites?

I'm developing a small WinForms program for home use - I have no intentions to releasing it anywhere.
Running it on my development machine, where I have Visual Studio and .NET and whatever else installed, works but deploying it on my PC, where I might not have all those frameworks, doesn't. I'm using some library written in C++ so I'm assuming I'm going to need some version of Visual C++ Redistributable, but I'm not sure which? And I'm not sure if that would be all. So, how can I determine an application's software prerequisites?
I used Dependency Walker and I got a message IEHIMS.DLL - Error opening file. The system cannot find the file specified (2), but that's all I could make out; there is so much information I'm having trouble make sense of it all. Besides, according to a quick google, IESHIMS.DLL has something to do with Internet Explorer, so it shouldn't really matter.
Thanks in advance to anyone taking to the time to consider my question.
Kind regards
For framework you can set the prerequisites for your application by going to project properties -> Publish -> Prerequisites. So now, if the required framework is not installed on the deployment machine, the setup will prompt for an install.
Now, for other dlls you are using, copy those dlls to your bin folder of the project and add the files while creating setup. This will solve the 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 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