I am using Visual Studio 2019 to build my C# .NET application, and I want to remove the names of functions/classes from the output file.
I have changed "Debugging information" in the project settings from Pdb-only to None, but I can still see the symbols by attaching a debugger (such as dnSpy) to the program.
I expect the built .exe file to not reveal the name of my functions and classes.
Related
I have a VC++ (.exe) application built in Visual Studio 2019. In project properties I have set to generate debug information for it.
Configuration Properties --> C/C++ --> Debug information format --> Program Database for Edit and Continue (/ZI)
Configuration Properties --> Linker --> Debugging --> Generate Debug Info --> Generate Debug Information (/DEBUG) (Also I have tried here: Generate Debug Information optimized for sharing and publishing (/DEBUG:FULL)
In the output it generates three files:
myApp.exe
myApp.pdb
myApp.Interop.dll
Now from another C# app I launched this VC++ exe app by using Process.Start("myapp.exe") in order to communicate between them later.
Now I am trying to debug C# and VC++ apps so I open two instances of VS, one for each app.
From VS I start debugging the C# app and from the another VS I attach to the process VC++ app. In the VS where I have launched my C# app, in modules window I can see below message:
C:\Users\myUser\AppData\Local\assembly\dl3\C23J1LN6.XOZ\GJPNWB74.YC1\bdcce8ba\10fb0e7d_e918d801\myApp.Interop.dll --> Binary was not built with debug information
Why isn't it capable to find my myApp.pdb file that was generated? all myApp.* are in the same directory.
It looks like an issue with the debugger type that you are using in the solution with the C# project. Visual Studio will default to "Managed only" when debugging a C# project. However, you want to debug both the C# project and the associated C++ dll. When trying to load the symbols for a native application / shared library it will fail as if there were no valid symbols.
Depending on how you attach to the C# executable:
if you are starting the executable directly from Visual Studio, you need to check "Enable native code debugging" in the Debug tab of your project properties [1];
if you are starting the executable externally and only later attaching using Visual Studio, you need to select "Native" and "Managed" clicking on the Select button in the "Attach to" row.
References
[1] https://learn.microsoft.com/en-us/visualstudio/debugger/how-to-debug-managed-and-native-code#configure-mixed-mode-debugging
[2] https://learn.microsoft.com/en-us/visualstudio/debugger/how-to-debug-in-mixed-mode
i have a simple c# app that is using DLL from another project which is compiled with debug: full mode
i can step into the code of the DLL but when I'm in the source code i can't click + jump to other source code that is related to the DLL.
how do i configure Visual Studio 2019 to be able to fully navigate the DLL I'm referencing
this is by the way is enable somehow by default in VC++
This is more of a comment/suggestion, but I needed multiple lines, check out the following
The other DLL needs to be built using the same framework version as the code you are searching from
as Paval said in Tools -> Options... -> Debugging -> General make sure the "Enable Just My Code" is not selected
When you are in 'source code' make sure the PDB for the dll you are referencing is in the build directory for the selected configuration
I have a solution with 4 projects, three of them are C++, and one is C#. I am trying to debug the C# one, but am unable to. Every single time I try, I get an error that says
Unable to start debugging. check your debugger settings by opening project properties and navigating to 'Configuration Properties -->Debugging'
Configuration is Debug, and the Platform is Any CPU. I am not debugging on a remote machine.
I have VS2017 installed on Windows 10.
Cannot Debug in VS2017 with Windows 10
According to the error message:
check your debugger settings by opening project properties and navigating to 'Configuration Properties -->Debugging'
This should be the debuger settings for C++ project rather than C# project:
C++:
C#:
So, first, you should make sure your StartUp Project is C# project. And for the C++ project, you can create a new blank C++ project, then compare the debugger settings of the problematic project with the settings of the new project.
Hope this helps.
I'm trying to debug a C# dll from a native C++ executable. I have a C# COM object that is loaded and run from native code via IDispatch. Everything is built in Debug, both C# and C++ code. Whilst I can see all the c++ code, and all the c++ dlls have their symbols loaded and available for debugging, breakpoints etc the C# code refuses to play.
What I do see is that the C# dlls all refuse to load their symbol pdbs, reporting "skipped loading symbols for ngen binary" in the modules window.
Incidentally, I am debugging the C# solution here, I have set the native executable as the 'start external program' in the COM project's debug settings.
Now I can start the C++ executable and then attach to it, and then all works as I expect - the symbols load and I can set breakpoints in the C#.
This is using Visual Studio 2013u4. Is there a setting to enable mixed-mode debugging? One niggle is that the native code was built with VS2010.
Here's the Module window - note all pdbs and dlls are in a single directory, you can see the c++ dlls loaded, but not the C# ones.
Here's the modules window - note the 3rd entry for the EvCom dll (the COM object) which I assume is the entry enabling debugging.
There is nothing of any interest in the Output window, when it comes to load the COM dll, I see the following (in the case of attach to running process, the other only has 2 Loaded lines instead of 3).
'Explorer.exe' (Win32): Loaded 'C:\Dev\...\lib\debug\EvCom.dll'.
'Explorer.exe' (Win32): Loaded 'C:\Dev\...\lib\debug\EvCom.dll'.
'Explorer.exe' (Win32): Unloaded 'C:\...\lib\debug\EvCom.dll'
'Explorer.exe' (Win32): Loaded 'C:\Dev\...\lib\debug\EvCom.dll'.
One thing of interest - I checked the "Use Managed Compatibility Mode" in the debug settings and, thought it still doesn't load my symbols when starting debugging, it only shows 1 entry in the modules list. This time saying "No native symbols in symbol file" for the C# dlls.
It looks like the problem is not being able to select the debugger type in VS2013 (or 2012). This connect article suggests its "by design" with some workarounds.
Turns out it is all down to the changes in debug engine for .NET 4.0
.NET 4 and greater uses a different debug engine than .net 3.5 and below, when you start debugging a native application the debugger will choose a .net debugger for you (defaults to .net 4.0) and if your .net dll is built using this platform, all will be well - breakpoints will be hit.
If your loaded dll is .net 3.5, then the debug engine will not understand the dlls that are loaded and will refuse to load symbols or debug.
The solutions are either to rebuild as .net 4, or start the native executable and attach to it (where you can select the debugger type, either 'old' .net or 'new' .net) or you can create a project from the executable and set its debug settings to specify the right debugger.
What I find annoying is that Microsoft could easily have started the debugger using the .NET framework type specified in the project you're debugging (after all, when debugging a dll and specifying an external program, you still want to debug the dll you're pressing F5 for, so you know what debugger to use!)(What is even more annoying is that once managed debugging is started in a loaded dll, you can then step into projects built using older .net frameworks without problem).
More details on this Microsoft connect article
(If your executable isn't already in your solution, File > Add > Existing project, then right-click and set it as start-up project.)
Right-click your start-up project, Properties, Debugging, Debugger Type = Mixed.
In my case I have own symbol server and TFS, so I
enabled option TOOLS > Options > Debugging > General > "Enable source server support" and three child options.
For me is was debugging a UWP app in Xamarin Forms:
Cause:
The debugger is skipping files not in the .NET environment.
Solution:
Uncheck Debugging => General => Enable Just My Code
All, I have a build installed on my machine and some functionality is working perfectly in code( in both modes release and debug) but that functionality is not working only in build.
So, I want to debug that .exe using attach to process. So, I start up the buid .exe from desktop shortcut and attach the visual studio to that .exe but visual studio says that no .pdb file is there, so it can't be debugged. So, one option is this
Build the project in debug mode and should copy the dll and pdb in the folder where build is installed in program files is that right??, will it work.
Or I have to do something else for debugging that code.
You can specify which pdb's visual studio needs to load when it starts the debugger.
Make sure they are the right version or you will need to specify on your breakpoints(via right clicking => location => allow source code to be different).
More info here
You should copy .PDB(symbol) files to the location where .EXE file exist, then VisualStudio would attach to process and let you start debuging process there.
Also, you can setup Microsoft symbol server.
Check this article
The easiest is to add the .pdb in the same directory as the .exe as already mentioned
Additionally, include or exclude pdbs:
Tools -> Options -> Debugging -> Symbols
Can either select all modules (with exclusions) or select specific modules to load
Disable just my code:
Tools -> Options -> Debugging -> General
Untick 'Just My Code'
Debug Microsoft libraries
You might want to add Microsoft's symbol server
Tools -> Options -> Debugging -> Symbols
Good to read http://msdn.microsoft.com/en-us/library/ms241613.aspx