Unable to attach matlab.exe process to visual studio 2013 for debugging mex files? - c++

I am writing some mex files to run in my matlab program using visual studio 2013 compiler.
In order to be able to debug your mex files, you should follow these steps
Everything was right just some minutes ago and I was doing my project without any problem.
Today I have typed the code
mex -g mx_minimum_power.cpp cvm_em64t_debug.lib
on command prompt many times and after getting the success message, I've attached matlab.exe to visual studio and through setting a break point, I've
debugged my code.
But this time I suddenly ran into the following error and I don't know how to solve it.
When I right-clicked on the third option and clicked run as administrator, I encountered the following message:
Then if I choose configure remote debugging, I'll encounter:
Now I have the following processes that are shown to be running.
and again:
When I click on permissions or options for remote debugger:

After running visual studio remote debugging monitor and getting the following message:
One should click the Find button in this window in order to find the msvsmon.exe that is being run on the subnet
and then choose MATLAB.exe, in the Available Processes list.

Related

Cant run C++ onto console in Visual Studio Code

Every time I click F5 to debug or run my code to console, I only receive an error message and im not so sure what to do. Im new to VSCode and help is highly appreciated.
I get an error saying: launch program " does not exist
Any advice as to what I should do? My OS is windows 10.
I've tried installing code runner and reinstalling visual studio all together. Though I cant find anything on the internet for any information.

How can I disable the debug console from showing the file address in my code?

I created a simple program for training purposes in Visual Studio Community Edition 2017 and I'm not having an issue running the program itself but it is showing me the file address for the process its running in the middle of the code in the Debug Console. I'm not sure how to disable this from showing.
I've tried searching Google but honestly I'm not sure how to easily phrase my question so no results really helped.
The program runs perfectly fine with no errors. This is a visual issue
Highlighted area is what I want to get rid of.
You can do it with:
Tools->Options->Debugging->Automatically close the console
Here is a corresponding fragment from the Visual Studio documentation:
Automatically close the console when debugging stops:
Tells Visual Studio to close the console at the end of a debugging session.

Unrecognized error occurred in the Windows Web Services framework

I'm trying to build and run a simple project in Visual Studio 2017 (C++) in x64 using the Local Windows Debugger. However every time I try to run it using the debugger I get this error.
This error doesn't show up when I change it from x64 to x86, but I need it to compile to x64. This has happened on both computers that I've tried it on, and seems to happen in every one of my projects. I've tried reinstalling Visual Studio already and nothing's changed. I've tried adding 'devenv.exe' as an exception to the Windows Firewall but no changes there either, even when I disabled the firewall completely. My antivirus isn't affecting it at all either: still happens when I disable it.
The application runs fine when I find it in the explorer and run it manually but then I don't have any debugging tools.
What am I doing wrong here, how do I make it build and run my project as x64?
I get this error every time I have an active VPN connection. If you use a VPN, try disconnect and see if the error disappears.
If you want to use a VPN, the solution (assuming you have Visual Studio 2017 Version 15.7 or later) is as follows:
Go to the Windows Start Menu and launch the “Developer Command Prompt for VS 2017 Preview”
Run: "%DevEnvDir%vsregedit.exe" set "%VSINSTALLDIR:~0,-1%" HKCU Debugger UseAnonymousPipes dword 1
Restart VS if it is already running
That solution is from this link to Microsoft.

Program does not proceed to console window

I'm using visual studio 2013 express. I have a program that uses recursion, after multiple edits and compiles. The compiler now compiles the program without error but the program does not run in foreground, instead 3 instances of same program run in the background. Task manager cannot stop the programs and i can no longer click and edit on visual studio(but is still responsive according to task manager). This code works on other systems.I have tried repairing visual studio, deleting debug folder, restarting my PC.
image showing build succeeded and 3 instances of program:
You might have missed to use the linker flag SUBSYSTEM:CONSOLE. MSDN link

Debug a mex function in Visual Studio

I'm trying to wrap existing C++ code into a MATLAB callable function. I'm using Visual Studio 2013 to generate the MEX file . The MEX file is created properly, I can call it from MATLAB and pass arguments back and forth without any issues.
Now I want to debug my C++ logic, and I can't seem to get it to work. I've created an m script that calls my function, and had Visual Studio run MATLAB when debugging - as explained here .
When I hit F5 to debug my MEX file, Visual Studio runs MATLAB, and then exits debug mode very quickly, as if the MATLAB process terminated. A few seconds after that, MATLAB starts running the code. It is as if the MATLAB instance I'm running starts another instance and terminates, confusing Visual Studio.
How can I debug my MEX function?
UPDATE: Apparantly MATLAB is doing exactly that, as described here. Adding the -wait argument makes Visual Studio wait until the script is done running, but the breakpoints I set don't work - because the process being debugged is not the process loading the DLL.
Turns out <MATLABROOT>\bin\matlab.exe actually runs <MATLABROOT>\bin\w64\matlab.exe. So if I ask Visual Studio to run that, breakpoints are triggered as expected.
Running MATLAB this way under the debugger is a lot slower than any other way, but at least now I can debug my code.
You could also run a MATLAB session as usual, and then attach Visual Studio to the running process. This is explained in more details in the documentation. Here is a quick summary:
compile the source MEX-file with debugging symbols enabled.
open the source C/C++ file in Visual Studio, and place a breakpoint.
start a normal MATLAB session. Then from Visual Studio, attach to the running matlab.exe process.
finally from MATLAB, run the MEX-function. You should hit the breakpoint with execution paused.