clrmd: System.DllNotFoundException
Hi,
we are using ClrMD in RavenDB to get stacktraces of our process. In most cases it works properly (had some issues with .NET 4.6 but latest version resolved that problem - thanks), but on some we are getting following exception:
System.DllNotFoundException: Unable to load DLL 'dbgeng.dll': The specified procedure could not be found. (Exception from HRESULT: 0x8007007F) at
Microsoft.Diagnostics.Runtime.Desktop.NativeMethods.DebugCreate(Guid& InterfaceId, Object& Interface) at
Microsoft.Diagnostics.Runtime.DbgEngDataReader.CreateIDebugClient() at
Microsoft.Diagnostics.Runtime.DbgEngDataReader..ctor(Int32 pid, AttachFlag flags, UInt32 msecTimeout) at
Microsoft.Diagnostics.Runtime.DataTarget.AttachToProcess(Int32 pid, UInt32 msecTimeout, AttachFlag attachFlag) at
Raven.Debug.Program.ShowStackTrace(Int32 processId, UInt32 attachTimeout, String outputPath) at
Raven.Debug.Program.Main(String[] args) at
Raven.Database.Server.Controllers.Admin.AdminController.DumpStacktrace(ZipArchive package) in c:\workspaces\HR\ravendb\Raven.Database\Server\Controllers\Admin\AdminController.cs:line 849
Not sure what is the reason and why it only happens on some machines.
I would appreciate your help/feedback.
This is how it works on our side:
- We are sending a request to a WebAPI controller
- Controller spawns new process to get the stacktraces (extracts the program from embedded resource): https://github.com/ayende/ravendb/blob/master/Raven.Database/Server/Controllers/Admin/AdminController.cs#L857
- The program is called Raven.Debug and can be found here: https://github.com/ppekrol/ravendb/blob/master/Raven.Debug/Program.cs#L53
Not sure if this can help, but on my machine I have a pretty fresh (1 month) Windows 10 Professional with VS2015 installed.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 19 (4 by maintainers)
FWIW, the following code (invoked before the first code of ClrMD is called) helped me with the issue:
Essentially, when called before ClrMD’s DllImport of dbgeng.dll has a chance to run, it not only loads dbgeng.dll from the Windows system directory, but also force it to look for its dependencies only there. That should prevent such dependencies to be loaded from other folders.