southpolenator / SharpDebug

C# debugging automation tool
MIT License
92 stars 30 forks source link

Exception in "!interactive" #7

Closed halsten closed 8 years ago

halsten commented 8 years ago

After loading the extension in WinDBG, and performing the command !CsDebugScript.interactive, the following error dump is thrown:

0:024> .load csext\CsDebugScript.WinDbg.dll 0:024> !CsDebugScript.interactive System.TypeInitializationException: The type initializer for 'CsDebugScript.Executor' threw an exception. ---> System.TypeInitializationException: The type initializer for 'CsDebugScript.ScriptCompiler' threw an exception. ---> System.IO.FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002) at System.Reflection.RuntimeAssembly.nLoadFile(String path, Evidence evidence) at System.Reflection.Assembly.LoadFile(String path) at CsDebugScript.ScriptCompiler.GetDefaultAssemblyReferences() in C:\Users\vujova\Documents\GitHub\WinDbgCs\Source\CsDebugScript.UI\ScriptCompiler.cs:line 62 at CsDebugScript.ScriptCompiler..cctor() in C:\Users\vujova\Documents\GitHub\WinDbgCs\Source\CsDebugScript.UI\ScriptCompiler.cs:line 36 --- End of inner exception stack trace --- at CsDebugScript.InteractiveExecution..ctor() in C:\Users\vujova\Documents\GitHub\WinDbgCs\Source\CsDebugScript.UI\InteractiveExecution.cs:line 47 at CsDebugScript.Executor..cctor() in C:\Users\vujova\Documents\GitHub\WinDbgCs\Source\CsDebugScript.UI\Executor.cs:line 19 --- End of inner exception stack trace --- at CsDebugScript.Executor.<>c.b__4_0() in C:\Users\vujova\Documents\GitHub\WinDbgCs\Source\CsDebugScript.UI\Executor.cs:line 58 at CsDebugScript.Engine.Debuggers.DbgEngDll.ExecuteAction(Action action) in C:\Users\vujova\Documents\GitHub\WinDbgCs\Source\CsDebugScript.Engine\Engine\Debuggers\DbgEngDll.cs:line 959

The culprit lines for future reference is the following line:

var assembly = Assembly.LoadFile(@"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\Microsoft.CSharp.dll");

For the time being, the only option is to copy that file in the same location as the extension. However, that would work only for 64bit machines if someone is using a 32bit machine that solution will not work.

--halsten

southpolenator commented 8 years ago

Fixed with check-in https://github.com/southpolenator/WinDbgCs/commit/26cb974db12e41c70e7863227314af648f940d61.