How to get .NET 5 symbols to show up in the call stack in Process Hacker or Process Explorer? - debugging

I created a simple console application in both .NET Framework 4.8 and .NET 5 (same code in both), but symbols resolve differently across various debugging tools.
If I run both applications, launch Process Hacker, open the process's properties, click on the Threads tab, and open the Stack for the primary managed thread, the .NET 4.8 Stack shows resolved symbols for my classes and methods, but the .NET 5 Stack does not -- it shows hex strings like 0x7ffbac6087a3.
In both cases, calls to System.Console.dll!System.Console.ReadKey() resolve correctly, so I know I have my symbol loading configured correctly (_NT_SYMBOL_PATH = "srv*C:\Source\symbols*https://msdl.microsoft.com/download/symbols"). In both cases, the projects are configured for full debug type and to include debug symbols. In both cases, there is a .pdb to go along with the .exe.
Sysinternals Process Explorer won't display any of that - the bottom of the call stack is 0x0.
If I take a dump of the applications, I can load them into WinDbg Preview and am able to see all of my code as expected. For the .NET 5 application, the normal Stack shows the same thing as Process Hacker (e.g. 0x7ffbac6087a3), but if I run the command !CLRStack -a, those hex values get properly resolved (e.g. 000000BD4F17E840 00007ffbac6087a3 SymbolsCoreConsoleApp.Program.Run() [C:\Source\research\SymbolsCore\SymbolsCoreConsoleApp\Program.cs # 18]).
So, there's the background. Here are the questions:
1.) Why doesn't the Process Hacker Stack resolve symbols for my classes in a .NET 5 application, but it does for the exact same code in a .NET Framework 4.8 application?
2.) Why doesn't Sysinternals Process Explorer display any of my code (just 0x0) for either application? In case it matters, I run procexp64.exe and my machine is x64 Windows 10 Enterprise. If I run 'procexp.exe`, it ultimately launches the x64 version anyhow. Mentioning this in case there is an issue with 32 vs. 64 bit.
3.) Both Process Hacker and Process Explorer have process tabs specifically for .NET (e.g. .NET assemblies and .NET performance), and those tabs only show up for the .NET Framework 4.8 application, but not for the .NET 5 application. Is this by-design or do I have something configured wrong?
4.) In WinDbg Preview, is this behavior by-design? If so, why?
5.) Are there other special things to consider when debugging/analyzing .NET 5/Core applications outside of Visual Studio?
That's a lot of questions, but they're all closely related, and I suspect there may be some fundamental thing(s) that I'm missing here.
Thanks in advance!
EDIT: 20210803 10:55 AM CDT
Per magicandre1981's comment, I installed the nightly of Process Hacker (v3.0.4234).
It still doesn't resolve those symbols.
It does show .NET assemblies and .NET performance tabs for the .NET 5 application now, but there are no values on the .NET performance tab.
EDIT: 20210803 05:05 PM CDT
I ran symchk and dumpbin against both of the applications in case this will help anyone diagnose the problem.
.NET 5
net5.0> $> pwd
C:\Source\research\SymbolsCore\SymbolsCoreConsoleApp\bin\Debug\net5.0
net5.0> $> & 'C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\symchk.exe' .\SymbolsCoreConsoleApp.exe /r
SYMCHK: FAILED files = 0
SYMCHK: PASSED + IGNORED files = 1
net5.0> $> & 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30037\bin\Hostx64\x64\dumpbin.exe' /PDBPATH:VERBOSE .\SymbolsCoreConsoleApp.exe
Microsoft (R) COFF/PE Dumper Version 14.29.30040.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file .\SymbolsCoreConsoleApp.exe
File Type: EXECUTABLE IMAGE
PDB file 'C:\Source\research\SymbolsCore\SymbolsCoreConsoleApp\bin\Debug\net5.0\apphost.pdb' checked. (File not found)
PDB file 'D:\workspace\_work\1\s\artifacts\obj\win-x64.Release\corehost\cli\apphost\standalone\Release\apphost.pdb' checked. (File not found)
PDB file 'C:\WINDOWS\symbols\exe\apphost.pdb' checked. (File not found)
PDB file 'C:\WINDOWS\exe\apphost.pdb' checked. (File not found)
PDB file 'C:\WINDOWS\apphost.pdb' checked. (File not found)
Summary
2000 .data
2000 .pdata
9000 .rdata
1000 .reloc
1000 .rsrc
14000 .text
1000 _RDATA
net5.0> $> & 'C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\symchk.exe' .\SymbolsCoreConsoleApp.dll /r
SYMCHK: SymbolsCoreConsoleApp.dll FAILED - SymbolsCoreConsoleApp.pdb mismatched or not found
SYMCHK: SymbolsCoreConsoleApp.dll FAILED - No CodeView information found.
SYMCHK: FAILED files = 2
SYMCHK: PASSED + IGNORED files = 0
net5.0> $> & 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30037\bin\Hostx64\x64\dumpbin.exe' /PDBPATH:VERBOSE .\SymbolsCoreConsoleApp.dll
Microsoft (R) COFF/PE Dumper Version 14.29.30040.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file .\SymbolsCoreConsoleApp.dll
File Type: EXECUTABLE IMAGE
PDB file found at 'C:\Source\research\SymbolsCore\SymbolsCoreConsoleApp\bin\Debug\net5.0\SymbolsCoreConsoleApp.pdb'
Summary
2000 .reloc
2000 .rsrc
2000 .text
.NET 4.8
Debug> $> pwd
C:\Source\research\SymbolsFramework\SymbolsFrameworkConsoleApp\bin\Debug
Debug> $> & 'C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\symchk.exe' .\SymbolsFrameworkConsoleApp.exe /r
SYMCHK: SymbolsFrameworkConsoleApp.exe FAILED - SymbolsFrameworkConsoleApp.pdb mismatched or not found
SYMCHK: FAILED files = 1
SYMCHK: PASSED + IGNORED files = 0
Debug> $> & 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30037\bin\Hostx64\x64\dumpbin.exe' /PDBPATH:VERBOSE .\SymbolsFrameworkConsoleApp.exe
Microsoft (R) COFF/PE Dumper Version 14.29.30040.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file .\SymbolsFrameworkConsoleApp.exe
File Type: EXECUTABLE IMAGE
PDB file found at 'C:\Source\research\SymbolsFramework\SymbolsFrameworkConsoleApp\bin\Debug\SymbolsFrameworkConsoleApp.pdb'
Summary
2000 .reloc
2000 .rsrc
2000 .text
EDIT: 20210803 07:54 PM CDT
Per hanpassant's comment, here is the project file (it already had the DebugType set to full).
SymbolsCoreConsoleApp.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
</Project>
EDIT: 20210803 08:40 PM CDT
Here are a few screenshots in case it wasn't clear from my explanation.
Notice the 0x7xfbb03a8 addresses instead of resolved symbols.
Notice the resolved symbols for SymbolsFramework.ConsoleApp.Program instead of the unresolved 0x7xfbb03a8 addresses.
Notice the 0x0 address instead of any resolved symbols.
The .NET Assemblies tab shows up for .NET 5 and appears to populate correctly.
The .NET Performance tab shows up for .NET 5, but it has no values.

I opened an issue with Process Hacker on GitHub and it was closed a few days back with a fix in the nightly build. I confirmed that it now works as expected.

Related

Visual Studio stops working when trying to debug wp8.1 [duplicate]

I'm using Visual Studio 2015 in a Windows 10 environment. Visual Studio is constantly crashing. The solution opens up fine, but after typing a few letters I get a message saying that an error occurred and Visual Studio must be shut down. I searched online and found how to run VS in diagnostic mode (devenv /log). I tried this and see several errors in ActivityLog.xml. I don't know what any of these mean and I can't find anything online about them. I've updated all of the Visual Studio extensions, but that didn't help. I tried repairing VS, but that didn't help either. Can someone explain how I can diagnose and fix the problem?
Here is the error messages in the log:
<entry>
<record>161</record>
<time>2017/05/08 14:53:38.815</time>
<type>Error</type>
<source>Microsoft.VisualStudio.CommonIDE.ExtensibilityHosting.VsShellComponentModelHost</source>
<description>Still unable to load MEF component DLL: Could not load file or assembly &apos;Microsoft.VisualStudio.Workspaces.Contracts, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&apos; or one of its dependencies. The system cannot find the file specified.</description>
<path>C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\EXTENSIONS\RV0KRPV2.PBV\TMLanguage.dll</path>
</entry>
<entry>
<record>162</record>
<time>2017/05/08 14:53:38.822</time>
<type>Error</type>
<source>Microsoft.VisualStudio.CommonIDE.ExtensibilityHosting.VsShellComponentModelHost</source>
<description>Still unable to load MEF component DLL: Could not load file or assembly &apos;Microsoft.VisualStudio.WindowsAzure.CommonAzureTools.Contracts.1.7, Version=1.7.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&apos; or one of its dependencies. The system cannot find the file specified.</description>
<path>C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\2re3mhbz.g1s\Microsoft.VisualStudio.ApplicationInsights.dll</path>
</entry>
<entry>
<record>163</record>
<time>2017/05/08 14:53:38.830</time>
<type>Error</type>
<source>Microsoft.VisualStudio.CommonIDE.ExtensibilityHosting.VsShellComponentModelHost</source>
<description>Still unable to load MEF component DLL: Could not load file or assembly &apos;Microsoft.VisualStudio.ApacheCordovaTools.Definitions.14.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&apos; or one of its dependencies. The system cannot find the file specified.</description>
<path>C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\EXTENSIONS\22KH2U4Y.XLJ\Microsoft.VisualStudio.Azure.ConnectedServices.MobileServices.dll</path>
</entry>
To diag Visual Studio crashes, you need to generate a crash dump, which includes the current state of Visual Studio.
To generate such a crash dump, you can configure Windows Error Reporting to generate dumps by running regedit.exe, go to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\devenv.exe create a string DumpFolder and give it a name like C:\localdumps and create a DWORD 32Bit named DumpType and set it to 2 to generate a Full dump.
After Visual Studio crashed and you got a dump, install the Debugging Tools for Windows, which are part of the Windows 10 SDK.
During Setup you only need to select the Debugging Tools for Windows
all other can be skipped.
Now run 32 Bit/x86 Windbg.exe (because Visual Studio is a 32Bit /x86 applciation), inside Windbg, setup the debug symbols, open the dmp via File->Open crash dump (or CTRL+D) and type !analyze -v in the command line at buttom
and now press ENTER. Now Windbg loads the required debug symbols and analyzes the dump and shows you some data. In my example I see this:
BUGCHECK_STR: CLR_EXCEPTION_REMOTE_System.NullReferenceException
DEFAULT_BUCKET_ID: CLR_EXCEPTION_REMOTE_System.NullReferenceException
PRIMARY_PROBLEM_CLASS: CLR_EXCEPTION
STACK_TEXT:
00000000 00000000 Microsoft_VisualStudio_Platform_WindowManagement_ni!Microsoft.VisualStudio.Platform.WindowManagement.DTE.MainWindow..ctor+0x0
00000000 00000000 Microsoft_VisualStudio_Platform_WindowManagement_ni!Microsoft.VisualStudio.Platform.WindowManagement.DTE.WindowBase.CreateMainWindow+0x0
00000000 00000000 Microsoft_VisualStudio_Platform_WindowManagement_ni!Microsoft.VisualStudio.Platform.WindowManagement.WindowManagerService.get_MainWindow+0x0
00000000 00000000 UNKNOWN!EnvDTE._DTE.get_MainWindow+0x1
00aed828 11da97b8 UNKNOWN!VSWindowTitleChanger.VSWindowTitleChangerPackage.DelayedInit+0x90
SYMBOL_NAME: Microsoft_VisualStudio_Platform_WindowManagement_ni!Microsoft.VisualStudio.Platform.WindowManagement.DTE.MainWindow..ctor
MODULE_NAME: Microsoft_VisualStudio_Platform_WindowManagement_ni
BUCKET_ID: CLR_EXCEPTION_REMOTE_System.NullReferenceException_Microsoft_VisualStudio_Platform_WindowManagement_ni!Microsoft.VisualStudio.Platform.WindowManagement.DTE.MainWindow..ctor
FAILURE_IMAGE_NAME: Microsoft.VisualStudio.Platform.WindowManagement.dll
BUCKET_ID_IMAGE_STR: Microsoft.VisualStudio.Platform.WindowManagement.dll
FAILURE_MODULE_NAME: Microsoft_VisualStudio_Platform_WindowManagement_ni
BUCKET_ID_MODULE_STR: Microsoft_VisualStudio_Platform_WindowManagement_ni
FAILURE_FUNCTION_NAME: Microsoft.VisualStudio.Platform.WindowManagement.DTE.MainWindow..ctor
BUCKET_ID_FUNCTION_STR: Microsoft.VisualStudio.Platform.WindowManagement.DTE.MainWindow..ctor
BUCKET_ID_PREFIX_STR: CLR_EXCEPTION_REMOTE_System.NullReferenceException_
So the Visual Studio crashed because of a System.NullReferenceException in the module VSWindowTitleChanger which tries to change the Title of a Window before it was laoded correctly and accessed an object with was NULL. This is a Visual Studio extension and removing it fixes the crash I had at startup.
If Windbg is too complicated, you can use the DebugDiag analyzer. 1st download the Debug Diagnostic Tool v2 Update 2, now run DebugDiag.Analysis.exe from C:\Program Files\DebugDiag, select CrashHangDumpAnalysis, now click on Add Data Files and select the dump.
In last step, click on Start Analysis. Now the analyzer checks the dump
and if this is finished, it opens a mht Report wit the result.

Unable to debug .NET Core app

I'm having and issue with Visual Studio and a .NET Core API project. It's been working fine but something must have changed because I'm now getting the following output when trying to debug the project:
The program '[18032] dotnet.exe' has exited with code -2147450749 (0x80008083).
The program '[17688] iisexpress.exe' has exited with code 0 (0x0).
The program '[5500] iexplore.exe' has exited with code -1 (0xffffffff).
The event viewer is showing this error:
Failed to start process with commandline '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\ProjectSystem\VSIISExeLauncher.exe" -debug -p "C:\Program Files (x86)\dotnet\dotnet.exe" -a "C:\Projects\Utilities\API\src\API\bin\Debug\netcoreapp1.0\API.dll" -pidFile "C:\Users\username\AppData\Local\Temp\tmp742C.tmp" -wd "C:\BlueSky\Utilities\API\src\API"', ErrorCode = '0x80004005'.
I'm not sure why this is happening, if anyone has any insight into this it would be appreciated.
Do as fallow:
Close Visual Studio
Delete the project.lock.json file (if exists)
If above step won't help then try to remove .vs folder
Open Visual Studio as Administrator (the file will be restored and you shouldn't have problems anymore)
There is also an option to use Kestrel instead of IIS Express but that's just an workaround.

visual studio 2015 c++ sddl.h does not appear as external dependency

I am trying to use the function ConvertSidToStringSid() in a Visual Studio 2015 Community, console project.
According to the msdn page
https://msdn.microsoft.com/en-us/library/windows/desktop/aa376399(v=vs.85).aspx
the requirements are:
Minimum supported client: Windows XP [desktop apps only]
Minimum supported server: Windows Server 2003 [desktop apps only]
Header: sddl.h
Library: Advapi32.lib
DLL: Advapi32.dll
I am using a Windows 10 Home, 64-bit computer. I have the *.lib and *.dll files respectively in :
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\um\x64\AdvAPI32.Lib
C:\Windows\System32\advapi32.dll
When i fill in the "#inclucde " in stdafx.h, I get no error from Intellisense. In contrast, "#include <blah.h>" gives a red wiggling underline under the 'include', and a mouse-over says 'Error: Cannot open source file "blah.h"'.
In my .cpp source file, which includes "stdafx.h", I add the code
BOOL OK ... ;
PSID owner;
char *sOwner;
OK = ConvertSidToStringSidW(owner, sOwner);
but then I get the red wiggle under ConvertSidToStringSidW.
In the solution explorer, under the project, under External dependencies there are files SCardErr.h and sdkddkver.h, but nothing, no sddl.h, between these two. (And, by the way, sddkver.h defines _WIN32_WINNT_THRESHOLD 0x0A00. Testing with IntelliSense in the editor, _WIN32_WINNT is also 0x0A00.)
When compiling, I first got an error message that the file sddl.h could not be found. I have multiple copies on the computer, and added to the "Additional include directories" for all configurations, the directory
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10586.0\shared
Compiling still fails with "identifier xxx is undefined" and 'xxx': Identifier not found, from IntelliSense and Build respectively.
The header sddl.h is still not in the external dependencies. Right-clicking on the sdksddkver.h I get its full path: The newly added additional include directory. I don't know what it was before I added this include directory.
Right clicking on the include directive in stdafx.h, I can open sddl.h. The editor shows parts of the contents in a light grey color, when the contents is guarded by an #if/#ifdef directive whose argument is false. However, the function I want to use, ConvertSidToStringSid, is shown in full color.
Unsure if its a clue that the error messages say "defined" rather than "declared". In the project properties, linker, input, additional dependencies, the file advapi32.lib is listed.
What am I doing wrong?
I found the solution myself. The problem was that I had two projects in the same "solution", each with its own stdafx.h file. I had the wrong stdafx.h file open in the editor, and placed the #include directive in the wrong file.
-Thanks

Analysis of dll

Is it possible to examine a dll, not installed in the registry, to see if it an ActiveX, the public methods, if it supports COM, etc. Is there some other tool with which to analyze a dll?
That's a very generic question, but you can analyze a dll's exported methods and ASM code using some decompiler/debugger like OllyDbg. Of course you need to have a good understanding of ASM and Windows inner workings.
http://www.ollydbg.de/version2.html
if you have Visual Studio and just want to know if the dll contains a COM component, you can open the visual studio command prompt, and use:
dumpbin /exports filename.dll
to show the dll's exported functions. If the dll exports DllGetClassObject, DllRegisterServer and DllUnregisterServer, it contains a COM component.
Example:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>dumpbin /exports c:\windows\system32\quartz.dll
Microsoft (R) COFF/PE Dumper Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file c:\windows\system32\quartz.dll
File Type: DLL
Section contains the following exports for QUARTZ.dll
00000000 characteristics
5215E909 time date stamp Thu Aug 22 12:33:45 2013
0.00 version
1 ordinal base
8 number of functions
8 number of names
ordinal hint RVA name
1 0 0003B34C AMGetErrorTextA
2 1 0003B41C AMGetErrorTextW
3 2 0003B2C8 AmpFactorToDB
4 3 0003B314 DBToAmpFactor
5 4 00002848 DllCanUnloadNow
6 5 000032E0 DllGetClassObject
7 6 0003AFA0 DllRegisterServer
8 7 0003B2A0 DllUnregisterServer
Summary
36000 .data
4000 .idata
F000 .pdata
4000 .reloc
B000 .rsrc
157000 .text
1000 RT_CODE

SSRS does not recognize custom DLL

I'm developing SSRS reports via VS2010 on my local machine.
I need to reference from a certain report to a DLL I wrote, The DLL was built at .net framwork 3.5 and I've placed the dll in the following libraries:
1.C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies.
2.C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer\bin
both on my local machine and the server where SSRS is located.
I've also added rssrvpolicy.config file as following:
<CodeGroup
class="UnionCodeGroup"
version="1"
PermissionSetName="FullTrust"
Name="Test"
Description="">
<IMembershipCondition
class="UrlMembershipCondition"
version="1"
Url="C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer\bin\Test.dll"
/>
Done all that' I've referenced the DLL through the report properties but yet recieved the following error message while previewing the report:
"An error occured during local report processing, The definition of the report X is invalid.
Error while loading code module "Test ...' Could not load file or assembly 'Test ...' or one of its dependenies. The system cannot find the file specified"
Any ideas?
OK found the problem!
Apperntly installing VS2010 on win7 64 bit create two Microsoft Visual Studio 10.0 folders, one in Program Files where I've located my DLL and one in Program Files (x86) where I should have located it.
Once the DLL was put in the correct folder the report recognized it.
Thanks for your reply

Resources