c# - ILSpy , NRefactory 'System.ArgumentException' -
i'm trying use dlls ildecompile 1 project, works fine of dlls i've tried decompile others i'm getting following error: unhandled exception of type 'system.argumentexception' occurred in icsharpcode.nrefactory.csharp.dll
i know error means have not find way fix/go around (since it's in dll).
i have used ildecompile , same dll throws above error works fine. can see in code of ilspy (that's using same dll) following piece of code:
if (child.parent != null) { throw new argumentexception("node used in tree.", "child"); }
this have ...
static string decompile(string pathtoassembly) { string assemblyname = pathtoassembly; decompilersettings settings = new decompilersettings(); settings.fullyqualifyambiguoustypenames = true; var resolver = new defaultassemblyresolver(); resolver.addsearchdirectory(path.getdirectoryname(pathtoassembly)); var parameters = new readerparameters { assemblyresolver = resolver }; assemblydefinition assembly1 = assemblydefinition.readassembly(assemblyname,parameters); decompilercontext decompilercontext = new decompilercontext(assembly1.mainmodule) { settings = settings } ; astbuilder decompiler = new astbuilder(decompilercontext); try { decompiler.addassembly(assembly1); } catch (exception ex) { console.writeline($"failed resolve assembly: "); console.writeline(ex.tostring()); } stringwriter output = new stringwriter(); decompiler.generatecode(new plaintextoutput(output)); // < here's error thrown. byte[] bytearray = encoding.ascii.getbytes(output.tostring()); textreader codereader = new streamreader(new memorystream(bytearray)); icsharpcode.decompiler.textoutputwriter test = new textoutputwriter(new plaintextoutput(output)); string line = codereader.readtoend(); return line; }
Comments
Post a Comment