.netdecompilingdnspy

dnSpy Console does not show any output


I need to automate .Net decompilation to C# using dnSpy. I downloaded it from https://github.com/dnSpy/dnSpy/releases/tag/v6.1.8 (x64 version on Win10 x64 computer) and unziped.

But when I try to run dnSpy.Console.exe from terminal (both Windows Command line and PowerShell) it just ends without logging any error or help info.

Running dnSpy.exe works just fine.

Are there any known issues regarding Console version?

I tried searching online, but no luck except on "how to mod and hack Unity games" tutorials.


Solution

  • You probably don't see any output because it logs on error which is not shown on your console.

    I got it to work by piping the cerr output into a file in linux:

    $ dnSpy.Console -o ./out/ ./Assembly-CSharp.dll 2> out.txt
    $ cat out.txt
    System.IO.IOException: The handle is invalid.
       at System.ConsolePal.SetConsoleOutputEncoding(Encoding enc)
       at System.Console.set_OutputEncoding(Encoding value)
       at dnSpy_Console.Program.Main(String[] args) in D:\a\dnSpy\dnSpy\dnSpy\dnSpy.Console\Program.cs:line 56
    Unhandled exception. System.IO.IOException: The handle is invalid.
       at System.ConsolePal.SetConsoleOutputEncoding(Encoding enc)
       at System.Console.set_OutputEncoding(Encoding value)
       at dnSpy_Console.Program.Main(String[] args) in D:\a\dnSpy\dnSpy\dnSpy\dnSpy.Console\Program.cs:line 65
    

    The exception message was of little help and I ended up using dnSpyEx instead, which is an unofficial continuation of dnSpy and seems to still be maintained. Worked like a charm.

    Here are the releases of dnSpyEx.