I have an assembly that contains a type named EncryptedStrings, and inside 
it is a method called DecryptString. I wanted to remove this method from 
the type and write the modified assembly back. I wrote this very simple 
code for it:

var file = @"path-to-file.exe"; 
var ass = AssemblyDefinition.ReadAssembly(file); // load assembly 
var type = ass.MainModule.GetType("EncryptedStrings"); // find the type 
var method = type.Methods.First(meth => meth.Name == "DecryptString"); // find 
the method in the 
type type.Methods.Remove(method); // remove the method 
ass.Write("fixed.exe"); // write assembly back 

However, when I run this code, I get an exception saying: 

System.ArgumentException: Member 'System.String 
DecryptString(System.String)' is declared in another module and needs to be 
imported


I have no idea what it wants from me... The method IS defined in that 
module, so what am I supposed to import?

What should I do to fix this and delete the method from the type?

Many thanks, I a noob, started using Cecil yesterday

-- 
-- 
--
mono-cecil
--- 
You received this message because you are subscribed to the Google Groups 
"mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mono-cecil/6146c1b4-6087-4ae9-9318-36808d48a95c%40googlegroups.com.

Reply via email to